From 199bd93696329a48acbcdfec4169a60864f3b392 Mon Sep 17 00:00:00 2001 From: Vincent Bernardoff Date: Tue, 29 Nov 2016 16:39:53 +0100 Subject: [PATCH] Lwt_utils: add may --- src/utils/lwt_utils.ml | 7 +++++-- src/utils/lwt_utils.mli | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/utils/lwt_utils.ml b/src/utils/lwt_utils.ml index 3a67511ec..3e4de7572 100644 --- a/src/utils/lwt_utils.ml +++ b/src/utils/lwt_utils.ml @@ -8,10 +8,13 @@ (**************************************************************************) module LC = Lwt_condition + +open Lwt.Infix open Logging.Core -let (>>=) = Lwt.(>>=) -let (>|=) = Lwt.(>|=) +let may f = function + | None -> Lwt.return_unit + | Some x -> f x let never_ending = fst (Lwt.wait ()) diff --git a/src/utils/lwt_utils.mli b/src/utils/lwt_utils.mli index 96c77b86a..2b3df7ac8 100644 --- a/src/utils/lwt_utils.mli +++ b/src/utils/lwt_utils.mli @@ -7,6 +7,8 @@ (* *) (**************************************************************************) +val may : ('a -> unit Lwt.t) -> 'a option -> unit Lwt.t + val never_ending: 'a Lwt.t val canceler : unit ->