diff --git a/src/lib_node_p2p/moving_average.ml b/src/lib_node_p2p/moving_average.ml index 33f06400e..7eb35ede5 100644 --- a/src/lib_node_p2p/moving_average.ml +++ b/src/lib_node_p2p/moving_average.ml @@ -53,8 +53,9 @@ let worker_loop () = let worker = lazy begin Lwt.async begin fun () -> - let (_cancelation, cancel, _on_cancel) = Lwt_utils.canceler () in - Lwt_utils.worker "counter" ~run:worker_loop ~cancel + Lwt_utils.worker "counter" + ~run:worker_loop + ~cancel:(fun _ -> Lwt.return_unit) end end diff --git a/src/lib_stdlib_lwt/lwt_utils.ml b/src/lib_stdlib_lwt/lwt_utils.ml index 7e4f807ff..f5ed75512 100644 --- a/src/lib_stdlib_lwt/lwt_utils.ml +++ b/src/lib_stdlib_lwt/lwt_utils.ml @@ -18,50 +18,6 @@ let may ~f = function let never_ending = fst (Lwt.wait ()) -(* A non exception-based cancelation mechanism. Builds a [cancelation] - thread to bind / pick on, awoken when a cancelation is requested by - [cancel ()]. [on_cancel cb] registers a callback to be called at - cancelation. [cancel ()] finishes when all calbacks have completed - (sequentially), instantly when called more than once. *) -let canceler () - : (unit -> unit Lwt.t) * - (unit -> unit Lwt.t) * - ((unit -> unit Lwt.t) -> unit) = - let cancelation = LC.create () in - let cancelation_complete = LC.create () in - let cancel_hook = ref (fun () -> Lwt.return ()) in - let canceling = ref false and canceled = ref false in - let cancel () = - if !canceled then - Lwt.return () - else if !canceling then - LC.wait cancelation_complete - else begin - canceling := true ; - LC.broadcast cancelation () ; - Lwt.finalize - !cancel_hook - (fun () -> - canceled := true ; - LC.broadcast cancelation_complete () ; - Lwt.return ()) >>= fun () -> - Lwt.return_unit - end - in - let on_cancel cb = - let hook = !cancel_hook in - cancel_hook := (fun () -> hook () >>= cb) ; - in - let cancelation () = - if !canceling then Lwt.return () - else LC.wait cancelation - in - cancelation, cancel, on_cancel - -module Idle_waiter = struct - -end - type trigger = | Absent | Present diff --git a/src/lib_stdlib_lwt/lwt_utils.mli b/src/lib_stdlib_lwt/lwt_utils.mli index 41e8b9766..2ebf9ccbb 100644 --- a/src/lib_stdlib_lwt/lwt_utils.mli +++ b/src/lib_stdlib_lwt/lwt_utils.mli @@ -11,11 +11,6 @@ val may: f:('a -> unit Lwt.t) -> 'a option -> unit Lwt.t val never_ending: 'a Lwt.t -val canceler: unit -> - (unit -> unit Lwt.t) * - (unit -> unit Lwt.t) * - ((unit -> unit Lwt.t) -> unit) - val worker: string -> run:(unit -> unit Lwt.t) ->