mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 03:05:30 -05:00
more sanity checks
This commit is contained in:
parent
63559f0f3b
commit
1eef212a3e
2 changed files with 5 additions and 2 deletions
|
|
@ -34,7 +34,7 @@ module Scheduler_state = struct
|
||||||
tasks = Queue.create ();
|
tasks = Queue.create ();
|
||||||
actions_from_other_threads = Queue.create ();
|
actions_from_other_threads = Queue.create ();
|
||||||
mutex = Mutex.create ();
|
mutex = Mutex.create ();
|
||||||
thread = Thread.self () |> Thread.id;
|
thread = -1;
|
||||||
closed = false;
|
closed = false;
|
||||||
as_runner = Moonpool.Runner.dummy;
|
as_runner = Moonpool.Runner.dummy;
|
||||||
enter_hook = None;
|
enter_hook = None;
|
||||||
|
|
@ -157,6 +157,8 @@ let await_lwt (fut : _ Lwt.t) =
|
||||||
)
|
)
|
||||||
|
|
||||||
let lwt_of_fut (fut : 'a M.Fut.t) : 'a Lwt.t =
|
let lwt_of_fut (fut : 'a M.Fut.t) : 'a Lwt.t =
|
||||||
|
if not (Ops.on_lwt_thread_ Scheduler_state.st) then
|
||||||
|
failwith "lwt_of_fut: not on the lwt thread";
|
||||||
let lwt_fut, lwt_prom = Lwt.wait () in
|
let lwt_fut, lwt_prom = Lwt.wait () in
|
||||||
|
|
||||||
(* in lwt thread, resolve [lwt_fut] *)
|
(* in lwt thread, resolve [lwt_fut] *)
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,8 @@ val fut_of_lwt : 'a Lwt.t -> 'a Moonpool.Fut.t
|
||||||
val lwt_of_fut : 'a Moonpool.Fut.t -> 'a Lwt.t
|
val lwt_of_fut : 'a Moonpool.Fut.t -> 'a Lwt.t
|
||||||
(** [lwt_of_fut fut] makes a lwt future that completes when [fut] does. This
|
(** [lwt_of_fut fut] makes a lwt future that completes when [fut] does. This
|
||||||
must be called from the Lwt thread, and the result must always be used only
|
must be called from the Lwt thread, and the result must always be used only
|
||||||
from inside the Lwt thread. *)
|
from inside the Lwt thread.
|
||||||
|
@raise Failure if not run from the lwt thread. *)
|
||||||
|
|
||||||
(** {2 Helpers on the moonpool side} *)
|
(** {2 Helpers on the moonpool side} *)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue