mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 11:15:38 -05:00
feat: add Fut.map_list
This commit is contained in:
parent
9de83bde6a
commit
1c94c59d88
2 changed files with 6 additions and 0 deletions
|
|
@ -330,6 +330,8 @@ let join_list (l : _ t list) : _ list t =
|
||||||
| [ x ] -> map ?on:None x ~f:(fun x -> [ x ])
|
| [ x ] -> map ?on:None x ~f:(fun x -> [ x ])
|
||||||
| _ -> join_container_ ~len:List.length ~map:List.map ~iter:List.iter l
|
| _ -> join_container_ ~len:List.length ~map:List.map ~iter:List.iter l
|
||||||
|
|
||||||
|
let[@inline] map_list ~f l : _ list t = List.map f l |> join_list
|
||||||
|
|
||||||
let wait_array (a : _ t array) : unit t =
|
let wait_array (a : _ t array) : unit t =
|
||||||
join_container_ a ~iter:Array.iter ~len:Array.length ~map:(fun _f _ -> ())
|
join_container_ a ~iter:Array.iter ~len:Array.length ~map:(fun _f _ -> ())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,10 @@ val join_array : 'a t array -> 'a array t
|
||||||
val join_list : 'a t list -> 'a list t
|
val join_list : 'a t list -> 'a list t
|
||||||
(** Wait for all the futures in the list. Fails if any future fails. *)
|
(** Wait for all the futures in the list. Fails if any future fails. *)
|
||||||
|
|
||||||
|
val map_list : f:('a -> 'b t) -> 'a list -> 'b list t
|
||||||
|
(** [map_list ~f l] is like [join_list @@ List.map f l].
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val wait_array : _ t array -> unit t
|
val wait_array : _ t array -> unit t
|
||||||
(** [wait_array arr] waits for all futures in [arr] to resolve. It discards
|
(** [wait_array arr] waits for all futures in [arr] to resolve. It discards
|
||||||
the individual results of futures in [arr]. It fails if any future fails. *)
|
the individual results of futures in [arr]. It fails if any future fails. *)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue