lwt_util.mli (2291B)
1 2 val join : unit Lwt.t list -> unit Lwt.t 3 (* [join l] wait for all threads in [l] to terminate. 4 If fails if one of the threads fail. *) 5 6 (****) 7 8 val iter : ('a -> unit Lwt.t) -> 'a list -> unit Lwt.t 9 (* [iter f l] start a thread for each element in [l]. The threads 10 are started according to the list order, but then can run 11 concurrently. It terminates when all the threads are 12 terminated, if all threads are successful. It fails if any of 13 the threads fail. *) 14 15 val map : ('a -> 'b Lwt.t) -> 'a list -> 'b list Lwt.t 16 (* [map f l] apply [f] to each element in [l] and collect the 17 results of the threads thus created. The threads are started 18 according to the list order, but then can run concurrently. 19 [map f l] fails if any of the threads fail. *) 20 21 val map_with_waiting_action : 22 ('a -> 'b Lwt.t) -> ('a -> unit) -> 'a list -> 'b list Lwt.t 23 (* [map_with_waiting_action f wa l] apply [f] to each element *) 24 (* in [l] and collect the results of the threads thus created. *) 25 (* The threads are started according to the list order, but *) 26 (* then can run concurrently. The difference with [map f l] is *) 27 (* that function wa will be called on the element that the *) 28 (* function is waiting for its termination. *) 29 30 val map_serial : ('a -> 'b Lwt.t) -> 'a list -> 'b list Lwt.t 31 (* Similar to [map] but wait for one thread to terminate before 32 starting the next one. *) 33 34 (****) 35 36 type region 37 38 val make_region : int -> region 39 (* [make_region sz] create a region of size [sz]. *) 40 val resize_region : region -> int -> unit 41 (* [resize_region reg sz] resize the region [reg] to size [sz]. *) 42 val run_in_region : region -> int -> (unit -> 'a Lwt.t) -> 'a Lwt.t 43 (* [run_in_region reg size f] execute the thread produced by the 44 function [f] in the region [reg]. The thread is not started 45 before some room is available in the region. *) 46 val purge_region : region -> unit 47 (* [purge_region reg] clear the queue of threads waiting to be 48 executed in the region [reg]. The waiting threads are not 49 woken (neither to execute nor to fail). Threads already being 50 executed in the region are not affected. *)