mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-10 05:03:58 -05:00
renaming
This commit is contained in:
parent
533b6e5ce2
commit
9cb10a79e6
3 changed files with 10 additions and 9 deletions
|
|
@ -171,7 +171,7 @@ let remove_on_cancel (self : _ t) h =
|
||||||
()
|
()
|
||||||
done
|
done
|
||||||
|
|
||||||
let with_cancel_callback (self : _ t) cb (k : unit -> 'a) : 'a =
|
let with_on_cancel (self : _ t) cb (k : unit -> 'a) : 'a =
|
||||||
let h = add_on_cancel self cb in
|
let h = add_on_cancel self cb in
|
||||||
Fun.protect k ~finally:(fun () -> remove_on_cancel self h)
|
Fun.protect k ~finally:(fun () -> remove_on_cancel self h)
|
||||||
|
|
||||||
|
|
@ -284,7 +284,7 @@ let[@inline] self () : any =
|
||||||
| None -> failwith "Fiber.self: must be run from inside a fiber."
|
| None -> failwith "Fiber.self: must be run from inside a fiber."
|
||||||
| Some f -> f
|
| Some f -> f
|
||||||
|
|
||||||
let with_self_cancel_callback cb (k : unit -> 'a) : 'a =
|
let with_on_self_cancel cb (k : unit -> 'a) : 'a =
|
||||||
let (Any self) = self () in
|
let (Any self) = self () in
|
||||||
let h = add_on_cancel self cb in
|
let h = add_on_cancel self cb in
|
||||||
Fun.protect k ~finally:(fun () -> remove_on_cancel self h)
|
Fun.protect k ~finally:(fun () -> remove_on_cancel self h)
|
||||||
|
|
|
||||||
|
|
@ -97,15 +97,16 @@ val remove_on_cancel : _ t -> cancel_handle -> unit
|
||||||
(** [remove_on_cancel fib h] removes the cancel callback
|
(** [remove_on_cancel fib h] removes the cancel callback
|
||||||
associated with handle [h]. *)
|
associated with handle [h]. *)
|
||||||
|
|
||||||
val with_cancel_callback : _ t -> cancel_callback -> (unit -> 'a) -> 'a
|
val with_on_cancel : _ t -> cancel_callback -> (unit -> 'a) -> 'a
|
||||||
(** [with_cancel_callback fib cb (fun () -> <e>)] evaluates [e]
|
(** [with_on_cancel fib cb (fun () -> <e>)] evaluates [e]
|
||||||
in a scope in which, if the fiber [fib] is cancelled,
|
in a scope in which, if the fiber [fib] is cancelled,
|
||||||
[cb()] is called. If [e] returns without the fiber being cancelled,
|
[cb()] is called. If [e] returns without the fiber being cancelled,
|
||||||
this callback is removed. *)
|
this callback is removed. *)
|
||||||
|
|
||||||
val with_self_cancel_callback : cancel_callback -> (unit -> 'a) -> 'a
|
val with_on_self_cancel : cancel_callback -> (unit -> 'a) -> 'a
|
||||||
(** [with_self_cancel_callback cb f] calls [f()] in a scope where
|
(** [with_on_self_cancel cb f] calls [f()] in a scope where
|
||||||
[cb] is added to the cancel callbacks of the current fiber *)
|
[cb] is added to the cancel callbacks of the current fiber;
|
||||||
|
and [f()] terminates, [cb] is removed from the list. *)
|
||||||
|
|
||||||
val on_result : 'a t -> 'a callback -> unit
|
val on_result : 'a t -> 'a callback -> unit
|
||||||
(** Wait for fiber to be done and call the callback
|
(** Wait for fiber to be done and call the callback
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ let () =
|
||||||
let fib =
|
let fib =
|
||||||
F.spawn_top ~on:runner @@ fun () ->
|
F.spawn_top ~on:runner @@ fun () ->
|
||||||
let@ () =
|
let@ () =
|
||||||
F.with_self_cancel_callback (fun ebt ->
|
F.with_on_self_cancel (fun ebt ->
|
||||||
logf (TS.tick_get clock) "main fiber cancelled with %s"
|
logf (TS.tick_get clock) "main fiber cancelled with %s"
|
||||||
@@ Exn_bt.show ebt)
|
@@ Exn_bt.show ebt)
|
||||||
in
|
in
|
||||||
|
|
@ -104,7 +104,7 @@ let () =
|
||||||
let clock = ref (0 :: i :: !clock) in
|
let clock = ref (0 :: i :: !clock) in
|
||||||
F.spawn ~protect:false @@ fun _n ->
|
F.spawn ~protect:false @@ fun _n ->
|
||||||
let@ () =
|
let@ () =
|
||||||
F.with_self_cancel_callback (fun _ ->
|
F.with_on_self_cancel (fun _ ->
|
||||||
logf (TS.tick_get clock) "sub-fiber %d was cancelled" i)
|
logf (TS.tick_get clock) "sub-fiber %d was cancelled" i)
|
||||||
in
|
in
|
||||||
Thread.delay (float i *. 0.001);
|
Thread.delay (float i *. 0.001);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue