add Fut.is_done

This commit is contained in:
Simon Cruanes 2023-06-15 10:24:20 -04:00
parent f18ed688e9
commit f76b713556
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
2 changed files with 9 additions and 0 deletions

View file

@ -28,6 +28,11 @@ let[@inline] peek self : _ option =
| Done x -> Some x
| Waiting _ -> None
let[@inline] is_done self : bool =
match A.get self.st with
| Done _ -> true
| Waiting _ -> false
exception Not_ready
let[@inline] get_or_fail self =

View file

@ -75,6 +75,10 @@ val get_or_fail_exn : 'a t -> 'a
@raise Not_ready if the future is not ready.
@since 0.2 *)
val is_done : _ t -> bool
(** Is the future resolved? This is the same as [peek fut |> Option.is_some].
@since 0.2 *)
(** {2 Combinators} *)
val spawn : on:Pool.t -> (unit -> 'a) -> 'a t