mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 03:05:30 -05:00
add Pool.shutdown_without_waiting
This commit is contained in:
parent
059ee8a1d5
commit
b451fde853
2 changed files with 9 additions and 2 deletions
|
|
@ -178,9 +178,12 @@ let create ?(on_init_thread = default_thread_init_exit_)
|
||||||
done;
|
done;
|
||||||
pool
|
pool
|
||||||
|
|
||||||
let shutdown (self : t) : unit =
|
let shutdown_ ~wait (self : t) : unit =
|
||||||
let was_active = A.exchange self.active false in
|
let was_active = A.exchange self.active false in
|
||||||
(* close the job queues, which will fail future calls to [run],
|
(* close the job queues, which will fail future calls to [run],
|
||||||
and wake up the subset of [self.threads] that are waiting on them. *)
|
and wake up the subset of [self.threads] that are waiting on them. *)
|
||||||
if was_active then Array.iter Bb_queue.close self.qs;
|
if was_active then Array.iter Bb_queue.close self.qs;
|
||||||
Array.iter Thread.join self.threads
|
if wait then Array.iter Thread.join self.threads
|
||||||
|
|
||||||
|
let shutdown_without_waiting (self : t) : unit = shutdown_ self ~wait:false
|
||||||
|
let shutdown (self : t) : unit = shutdown_ self ~wait:true
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,10 @@ val num_tasks : t -> int
|
||||||
val shutdown : t -> unit
|
val shutdown : t -> unit
|
||||||
(** Shutdown the pool and wait for it to terminate. Idempotent. *)
|
(** Shutdown the pool and wait for it to terminate. Idempotent. *)
|
||||||
|
|
||||||
|
val shutdown_without_waiting : t -> unit
|
||||||
|
(** Shutdown the pool, and do not wait for it to terminate. Idempotent.
|
||||||
|
@since 0.2 *)
|
||||||
|
|
||||||
exception Shutdown
|
exception Shutdown
|
||||||
|
|
||||||
val run : t -> (unit -> unit) -> unit
|
val run : t -> (unit -> unit) -> unit
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue