Module Stm.QueryTask
type taskMain description of a task. Elements are stored in the "master" process, and then converted into a request.
type competencecompetencestores the information about what kind of work a worker has completed / has available.
type worker_status=|Fresh|Old of competenceA worker_status is:
`Freshwhen a worker is born.
`Old of competence: When a worker ends a job it can either die (and be replaced by a fresh new worker) or hang there as an`Oldworker. In such case some data can be carried by the`Oldconstructor, typically used to implementrequest_of_task.
This allows to implement both one-shot workers and "persistent" ones. E.g. par: is implement using workers that don't "reboot". Proof workers do reboot mainly because the vm has some C state that cannot be cleared, so you have a real memory leak if you don't reboot the worker.
type requestType of input and output data for workers.
The data must be marshallable as it send through the network using
Marshal.
Master API, it is run by the master, on a thread
val request_of_task : worker_status -> task -> request optionrequest_of_task status ttakes thestatusof the worker and a tasktand creates the correspondingSome requestto be sent to the worker or it is not valid anymoreNone.
val task_match : worker_status -> task -> booltask_match status tidAllows to discard tasks based on the worker status.
val use_response : worker_status -> task -> response -> [ `Stay of competence * task list | `End ]use_response status t outFor a response
outto a tasktwithstatuswe can choose to end the worker of to keep it alive with some data and immediately inject extra tasks in the queue.For example, the proof worker runs a proof and finds an error, the response signals that, e.g.
ReponseError {state = 34; msg = "oops"}When the manager uses such a response he can tell the worker to stay there and inject into the queue an extra task requesting state 33 (to implement efficient proof repair).
val on_marshal_error : string -> task -> uniton_marshal_error err_msg tidnotifies of marshaling failure.
val on_task_cancellation_or_expiration_or_slave_death : task option -> uniton_task_cancellation_or_expiration_or_slave_death tidThese functions are meant to parametrize the worker manager on the actions to be taken when things go wrong or are cancelled (you can kill a worker in CoqIDE, or using kill -9...)
E.g. master can decide to inhabit the (delegate) Future.t with a closure (to be run in master), i.e. make the document still checkable. This is what I do for marshaling errors.
val forward_feedback : Feedback.feedback -> unitforward_feedback fbsends fb to all the workers.
Worker API, it is run by worker, on a different fresh process
val name_of_task : task -> stringdebugging
val name_of_request : request -> string