mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
added Futures.is_done function;
.ocamlinit file to import stuff in the toplevel
This commit is contained in:
parent
579746810e
commit
23029332df
3 changed files with 20 additions and 0 deletions
7
.ocamlinit
Normal file
7
.ocamlinit
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
(* vim:syntax=ocaml: *)
|
||||
#use "topfind";;
|
||||
#directory "_build/";;
|
||||
#directory "_build/tests/";;
|
||||
#load "containers.cma";;
|
||||
#require "threads";;
|
||||
#load "thread_containers.cma";;
|
||||
10
futures.ml
10
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 =
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue