add Pool.num_tasks

This commit is contained in:
Simon Cruanes 2023-06-15 10:35:41 -04:00
parent f76b713556
commit 059ee8a1d5
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
2 changed files with 11 additions and 1 deletions

View file

@ -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

View file

@ -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. *)