mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 03:05:30 -05:00
wip
This commit is contained in:
parent
b53a067234
commit
89b8ed3221
1 changed files with 12 additions and 11 deletions
|
|
@ -102,11 +102,12 @@ end
|
||||||
module Fine_grained (Args : FINE_GRAINED_ARGS) () = struct
|
module Fine_grained (Args : FINE_GRAINED_ARGS) () = struct
|
||||||
open Args
|
open Args
|
||||||
|
|
||||||
let cur_st : Runner.For_runner_implementors.thread_local_state =
|
let cur_st : Runner.For_runner_implementors.thread_local_state Lazy.t =
|
||||||
match TLS.get_exn Runner.For_runner_implementors.k_cur_st with
|
lazy
|
||||||
| st -> st
|
(match TLS.get_exn Runner.For_runner_implementors.k_cur_st with
|
||||||
| exception TLS.Not_set ->
|
| st -> st
|
||||||
failwith "Moonpool: worker loop: no current state set"
|
| exception TLS.Not_set ->
|
||||||
|
failwith "Moonpool: worker loop: no current state set")
|
||||||
|
|
||||||
let runner = ops.runner st
|
let runner = ops.runner st
|
||||||
|
|
||||||
|
|
@ -123,7 +124,7 @@ module Fine_grained (Args : FINE_GRAINED_ARGS) () = struct
|
||||||
| T_start { fiber; _ } | T_resume { fiber; _ } -> fiber
|
| T_start { fiber; _ } | T_resume { fiber; _ } -> fiber
|
||||||
in
|
in
|
||||||
|
|
||||||
cur_st.cur_fiber <- fiber;
|
(Lazy.force cur_st).cur_fiber <- fiber;
|
||||||
|
|
||||||
(* run the task now, catching errors, handling effects *)
|
(* run the task now, catching errors, handling effects *)
|
||||||
assert (task != _dummy_task);
|
assert (task != _dummy_task);
|
||||||
|
|
@ -138,7 +139,7 @@ module Fine_grained (Args : FINE_GRAINED_ARGS) () = struct
|
||||||
let ebt = Exn_bt.make e bt in
|
let ebt = Exn_bt.make e bt in
|
||||||
ops.on_exn st ebt);
|
ops.on_exn st ebt);
|
||||||
|
|
||||||
cur_st.cur_fiber <- _dummy_fiber
|
(Lazy.force cur_st).cur_fiber <- _dummy_fiber
|
||||||
|
|
||||||
let setup ~block_signals () : unit =
|
let setup ~block_signals () : unit =
|
||||||
if !state <> New then invalid_arg "worker_loop.setup: not a new instance";
|
if !state <> New then invalid_arg "worker_loop.setup: not a new instance";
|
||||||
|
|
@ -161,9 +162,9 @@ module Fine_grained (Args : FINE_GRAINED_ARGS) () = struct
|
||||||
with _ -> ()
|
with _ -> ()
|
||||||
);
|
);
|
||||||
|
|
||||||
cur_st.runner <- runner;
|
ops.before_start st;
|
||||||
|
(Lazy.force cur_st).runner <- runner;
|
||||||
ops.before_start st
|
()
|
||||||
|
|
||||||
let run ?(max_tasks = max_int) () : unit =
|
let run ?(max_tasks = max_int) () : unit =
|
||||||
if !state <> Ready then invalid_arg "worker_loop.run: not setup";
|
if !state <> Ready then invalid_arg "worker_loop.run: not setup";
|
||||||
|
|
@ -181,7 +182,7 @@ module Fine_grained (Args : FINE_GRAINED_ARGS) () = struct
|
||||||
let teardown () =
|
let teardown () =
|
||||||
if !state <> Torn_down then (
|
if !state <> Torn_down then (
|
||||||
state := Torn_down;
|
state := Torn_down;
|
||||||
cur_st.cur_fiber <- _dummy_fiber;
|
(Lazy.force cur_st).cur_fiber <- _dummy_fiber;
|
||||||
ops.cleanup st
|
ops.cleanup st
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue