diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/future.ml | 8 | ||||
| -rw-r--r-- | lib/future.mli | 3 |
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/future.ml b/lib/future.ml index 292fd6648a..3cbaa95dc5 100644 --- a/lib/future.ml +++ b/lib/future.ml @@ -59,9 +59,15 @@ let proj = function let create f = ref (Closure f) +type 'a assignement = [ `Val of 'a | `Exn of exn | `Comp of 'a computation] let create_delegate () = let c = ref Delegated in - c, (function `Val v -> c := Val (v, None) | `Exn e -> c := Exn e) + c, (fun v -> + assert (!c = Delegated); + match v with + | `Val v -> c := Val (v, None) + | `Exn e -> c := Exn e + | `Comp f -> c := !f) (* TODO: get rid of try/catch *) let compute ~pure c : 'a value = match !c with diff --git a/lib/future.mli b/lib/future.mli index 3da0e2fdc7..39be0c1806 100644 --- a/lib/future.mli +++ b/lib/future.mli @@ -19,7 +19,8 @@ val create : (unit -> 'a) -> 'a computation val from_val : 'a -> 'a computation (* Run remotely, returns the function to assign *) -val create_delegate : unit -> 'a computation * ('a value -> unit) +type 'a assignement = [ `Val of 'a | `Exn of exn | `Comp of 'a computation] +val create_delegate : unit -> 'a computation * ('a assignement -> unit) (* Variants to stock a copy of the current environment *) val create_here : (unit -> 'a) -> 'a computation |
