diff --git a/.ocamlinit b/.ocamlinit new file mode 100644 index 00000000..afbd4804 --- /dev/null +++ b/.ocamlinit @@ -0,0 +1,7 @@ +(* vim:syntax=ocaml: *) +#use "topfind";; +#directory "_build/";; +#directory "_build/tests/";; +#load "containers.cma";; +#require "threads";; +#load "thread_containers.cma";; diff --git a/futures.ml b/futures.ml index a477243f..d061f088 100644 --- a/futures.ml +++ b/futures.ml @@ -155,6 +155,16 @@ let fail future e = Mutex.unlock future.mutex; raise SendTwice (* already set! *) +let is_done future = + Mutex.lock future.mutex; + match future.content with + | NotKnown -> + Mutex.unlock future.mutex; + false + | _ -> + Mutex.unlock future.mutex; + true + (** {2 Combinators *) let flatMap ?(pool=default_pool) f future = diff --git a/futures.mli b/futures.mli index 1fdb8952..58e6b2a7 100644 --- a/futures.mli +++ b/futures.mli @@ -65,6 +65,9 @@ val send : 'a t -> 'a -> unit val fail : 'a t -> exn -> unit (** Fail the future by raising an exception inside it *) +val is_done : 'a t -> bool + (** Is the future evaluated (success/failure)? *) + (** {2 Combinators *) val flatMap : ?pool:Pool.t -> ('a -> 'b t) -> 'a t -> 'b t