package coq-core
Install
Dune Dependency
Authors
Maintainers
Sources
md5=8d852367b54f095d9fbabd000304d450
sha512=46922d5f2eb6802a148a52fd3e7f0be8370c93e7bc33cee05cf4a2044290845b10ccddbaa306f29c808e7c5019700763e37e45ff6deb507b874a4348010fed50
doc/coq-core.stm/AsyncTaskQueue/MakeQueue/index.html
Module AsyncTaskQueue.MakeQueue
Source
Client-side functor. MakeQueue T
creates a task queue for task T
Parameters
Signature
queue
is the abstract queue type.
create n pri
will initialize the queue with n
workers having priority pri
. If n
is 0, the queue won't spawn any process, working in a lazy local manner. not imposed by the this API
enqueue_task q t ~cancel_switch
schedules t
for execution in q
. cancel_switch
can be flipped to true to cancel the task.
cancel_worker q wid
cancels a particular worker wid
set_order q cmp
reorders q
using ordering cmp
broadcast q
This is nasty. Workers can be picky, e.g. pick tasks only when they are "on screen". Of course the screen is scrolled, and that changes the potential choice of workers to pick up a task or not.
This function wakes up the workers (the managers) that give a look (again) to the tasks in the queue.
The STM calls it when the perspective (as in PIDE) changes.
A problem here is that why task_match has access to the competence data in order to decide if the task is palatable to the worker or not... such data is local to the worker (manager). The perspective is global, so it does not quite fit this picture. This API to make all managers reconsider the tasks in the queue is the best I could came up with.
This API is crucial to Coqoon (or any other UI that invokes Stm.finish eagerly but wants the workers to "focus" on the visible part of the document).
snapshot q
Takes a snapshot (non destructive but waits until all workers are enqueued)
with_n_workers n pri f
creates a queue, runs the function, destroys the queue. The user should call join