module Lwt_pool:sig
..end
type 'a
t
val create : int ->
?check:('a -> (bool -> unit) -> unit) ->
?validate:('a -> bool Lwt.t) -> (unit -> 'a Lwt.t) -> 'a t
create n ?check ?validate f
creates a new pool with at most
n
members. f
is the function to use to create a new pool
member.
An element of the pool is validated by the optional validate
function before its Lwt_pool.use
. Invalid elements are re-created.
The optional function check
is called after a use
of an
element failed. It must call its argument excatly one with
true
if the pool member is still valid and false
otherwise.
val use : 'a t -> ('a -> 'b Lwt.t) -> 'b Lwt.t
use p f
takes one free member of the pool p
and gives it to
the function f
.