mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-14 06:46:15 -05:00
feat pool: use Shutdown when running a task after it's closed
This commit is contained in:
parent
9a1309c44f
commit
3f720241b2
2 changed files with 5 additions and 5 deletions
|
|
@ -67,7 +67,9 @@ let run_direct_ (self : state) (w : worker_state option) (task : task) : unit =
|
|||
if was_empty then Condition.broadcast self.mc.cond;
|
||||
Mutex.unlock self.mc.mutex
|
||||
) else
|
||||
raise Bb_queue.Closed
|
||||
(* notify the caller that scheduling tasks is no
|
||||
longer permitted *)
|
||||
raise Shutdown
|
||||
|
||||
let run_async_ (self : state) (task : task) : unit =
|
||||
(* stay on current worker if possible *)
|
||||
|
|
@ -185,7 +187,7 @@ let worker_thread_ (self : state) (runner : t) (w : worker_state) ~on_exn
|
|||
raise_notrace (Got_task task)
|
||||
done;
|
||||
Mutex.unlock self.mc.mutex;
|
||||
raise Bb_queue.Closed
|
||||
raise Shutdown
|
||||
with Got_task t -> t
|
||||
in
|
||||
|
||||
|
|
@ -199,7 +201,7 @@ let worker_thread_ (self : state) (runner : t) (w : worker_state) ~on_exn
|
|||
run_task task
|
||||
)
|
||||
done
|
||||
with Bb_queue.Closed -> ());
|
||||
with Shutdown -> ());
|
||||
run_self_tasks_ ()
|
||||
in
|
||||
|
||||
|
|
|
|||
|
|
@ -34,8 +34,6 @@ type ('a, 'b) create_args =
|
|||
'a
|
||||
(** Arguments used in {!create}. See {!create} for explanations. *)
|
||||
|
||||
exception Closed
|
||||
|
||||
val create : (unit -> t, _) create_args
|
||||
(** [create ()] makes a new thread pool.
|
||||
@param on_init_thread called at the beginning of each new thread
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue