Module AsyncTaskQueue.MakeQueue
Client-side functor. MakeQueue T creates a task queue for task T
Parameters
Signature
- val create : int -> CoqworkmgrApi.priority -> queue
- create n priwill initialize the queue with- nworkers having priority- pri. If- nis 0, the queue won't spawn any process, working in a lazy local manner.- not imposed by the this API
- val destroy : queue -> unit
- destroy qDeallocates- q, cancelling all pending tasks.
- val n_workers : queue -> int
- n_workers qreturns the number of workers of- q
- val enqueue_task : queue -> T.task -> cancel_switch:cancel_switch -> unit
- enqueue_task q t ~cancel_switchschedules- tfor execution in- q.- cancel_switchcan be flipped to true to cancel the task.
- val join : queue -> unit
- join qblocks until the task queue is empty
- val cancel_all : queue -> unit
- cancel_all qCancels all tasks
- val cancel_worker : queue -> WorkerPool.worker_id -> unit
- cancel_worker q widcancels a particular worker- wid
- val set_order : queue -> (T.task -> T.task -> int) -> unit
- set_order q cmpreorders- qusing ordering- cmp
- val broadcast : queue -> unit
- 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). 
- val snapshot : queue -> T.task list
- snapshot qTakes a snapshot (non destructive but waits until all workers are enqueued)
- val clear : queue -> unit
- clear qClears- q, only if the worker prool is empty
- val with_n_workers : int -> CoqworkmgrApi.priority -> (queue -> 'a) -> 'a
- with_n_workers n pri fcreates a queue, runs the function, destroys the queue. The user should call join