mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 03:05:30 -05:00
fifo pool: format, use with_suspend unconditionally
This commit is contained in:
parent
e94c7999de
commit
b9cf0616b8
1 changed files with 9 additions and 15 deletions
|
|
@ -25,7 +25,9 @@ let schedule_ (self : state) (task : task_full) : unit =
|
|||
type around_task = AT_pair : (t -> 'a) * (t -> 'a -> unit) -> around_task
|
||||
|
||||
let worker_thread_ (self : state) (runner : t) ~on_exn ~around_task : unit =
|
||||
let cur_ls : Task_local_storage.storage ref = ref Task_local_storage.Private_.Storage.dummy in
|
||||
let cur_ls : Task_local_storage.storage ref =
|
||||
ref Task_local_storage.Private_.Storage.dummy
|
||||
in
|
||||
TLS.set k_storage (Some cur_ls);
|
||||
TLS.get Runner.For_runner_implementors.k_cur_runner := Some runner;
|
||||
|
||||
|
|
@ -52,21 +54,13 @@ let worker_thread_ (self : state) (runner : t) ~on_exn ~around_task : unit =
|
|||
cur_ls := task.ls;
|
||||
let _ctx = before_task runner in
|
||||
|
||||
let resume ls k res =
|
||||
schedule_ self { f = (fun () -> k res); ls }
|
||||
in
|
||||
let resume ls k res = schedule_ self { f = (fun () -> k res); ls } in
|
||||
|
||||
(* run the task now, catching errors, handling effects *)
|
||||
(try
|
||||
[@@@ifge 5.0]
|
||||
Suspend_.with_suspend (WSH {
|
||||
run=run_another_task;
|
||||
resume;
|
||||
on_suspend;
|
||||
}) task.f
|
||||
[@@@else_]
|
||||
task.f()
|
||||
[@@@endif]
|
||||
Suspend_.with_suspend
|
||||
(WSH { run = run_another_task; resume; on_suspend })
|
||||
task.f
|
||||
with e ->
|
||||
let bt = Printexc.get_raw_backtrace () in
|
||||
on_exn e bt);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue