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;
|
if was_empty then Condition.broadcast self.mc.cond;
|
||||||
Mutex.unlock self.mc.mutex
|
Mutex.unlock self.mc.mutex
|
||||||
) else
|
) 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 =
|
let run_async_ (self : state) (task : task) : unit =
|
||||||
(* stay on current worker if possible *)
|
(* 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)
|
raise_notrace (Got_task task)
|
||||||
done;
|
done;
|
||||||
Mutex.unlock self.mc.mutex;
|
Mutex.unlock self.mc.mutex;
|
||||||
raise Bb_queue.Closed
|
raise Shutdown
|
||||||
with Got_task t -> t
|
with Got_task t -> t
|
||||||
in
|
in
|
||||||
|
|
||||||
|
|
@ -199,7 +201,7 @@ let worker_thread_ (self : state) (runner : t) (w : worker_state) ~on_exn
|
||||||
run_task task
|
run_task task
|
||||||
)
|
)
|
||||||
done
|
done
|
||||||
with Bb_queue.Closed -> ());
|
with Shutdown -> ());
|
||||||
run_self_tasks_ ()
|
run_self_tasks_ ()
|
||||||
in
|
in
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,6 @@ type ('a, 'b) create_args =
|
||||||
'a
|
'a
|
||||||
(** Arguments used in {!create}. See {!create} for explanations. *)
|
(** Arguments used in {!create}. See {!create} for explanations. *)
|
||||||
|
|
||||||
exception Closed
|
|
||||||
|
|
||||||
val create : (unit -> t, _) create_args
|
val create : (unit -> t, _) create_args
|
||||||
(** [create ()] makes a new thread pool.
|
(** [create ()] makes a new thread pool.
|
||||||
@param on_init_thread called at the beginning of each new thread
|
@param on_init_thread called at the beginning of each new thread
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue