lwt
Library
Module
Module type
Parameter
Class
Class type
val create :
int ->
?validate:( 'a -> bool Lwt.t ) ->
?check:( 'a -> ( bool -> unit ) -> unit ) ->
?dispose:( 'a -> unit Lwt.t ) ->
( unit -> 'a Lwt.t ) ->
'a t
create n ?check ?validate ?dispose f
creates a new pool with at most n
elements. f
is used to create a new pool element. Elements are created on demand and re-used until disposed of.
use p f
takes one free element of the pool p
and gives it to the function f
. The element is put back into the pool after the promise created by f
completes.
clear p
will clear all elements in p
, calling the dispose
function associated with p
on each of the cleared elements. Any elements from p
which are currently in use will be disposed of once they are released.
The next call to use p
after clear p
guarantees a freshly created pool element.
Disposals are performed sequentially in an undefined order.
val wait_queue_length : _ t -> int
wait_queue_length p
returns the number of threads currently waiting for an element of the pool p
to become available.