added Futures.is_done function;

.ocamlinit file to import stuff in the toplevel
This commit is contained in:
Simon Cruanes 2013-03-19 15:10:41 +01:00
parent 579746810e
commit 23029332df
3 changed files with 20 additions and 0 deletions

7
.ocamlinit Normal file
View file

@ -0,0 +1,7 @@
(* vim:syntax=ocaml: *)
#use "topfind";;
#directory "_build/";;
#directory "_build/tests/";;
#load "containers.cma";;
#require "threads";;
#load "thread_containers.cma";;

View file

@ -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 =

View file

@ -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