mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 03:05:30 -05:00
add Pool.num_tasks
This commit is contained in:
parent
f76b713556
commit
059ee8a1d5
2 changed files with 11 additions and 1 deletions
|
|
@ -51,7 +51,12 @@ let run (self : t) (f : task) : unit =
|
|||
| Exit -> ()
|
||||
| Bb_queue.Closed -> raise Shutdown
|
||||
|
||||
let size self = Array.length self.threads
|
||||
let[@inline] size self = Array.length self.threads
|
||||
|
||||
let num_tasks (self : t) : int =
|
||||
let n = ref 0 in
|
||||
Array.iter (fun q -> n := !n + Bb_queue.size q) self.qs;
|
||||
!n
|
||||
|
||||
exception Got_task of task
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,11 @@ val create :
|
|||
val size : t -> int
|
||||
(** Number of threads *)
|
||||
|
||||
val num_tasks : t -> int
|
||||
(** Current number of tasks. This is at best a snapshot, useful for metrics
|
||||
and debugging.
|
||||
@since 0.2 *)
|
||||
|
||||
val shutdown : t -> unit
|
||||
(** Shutdown the pool and wait for it to terminate. Idempotent. *)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue