mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-05 19:00:33 -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 ();
|
||||
actions_from_other_threads = Queue.create ();
|
||||
mutex = Mutex.create ();
|
||||
thread = Thread.self () |> Thread.id;
|
||||
thread = -1;
|
||||
closed = false;
|
||||
as_runner = Moonpool.Runner.dummy;
|
||||
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 =
|
||||
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
|
||||
|
||||
(* 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
|
||||
(** [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
|
||||
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} *)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue