package fuseau
-
fuseau.unix
Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
Resource pool.
This pool can be used for buffers. It can be used for other resources but do note that it assumes resources are still reasonably cheap to produce and discard, and will never block waiting for a resource — it's not a good pool for DB connections.
val create :
?clear:('a -> unit) ->
mk_item:(unit -> 'a) ->
?max_size:int ->
unit ->
'a t
Create a new pool.
val acquire : 'a t -> 'a
Acquire (or create) a new resource from the pool.
val recycle : 'a t -> 'a -> unit
Recycle a value into the pool. The value must not be used afterwards.
val with_resource : 'a t -> ('a -> 'b) -> 'b
with_resource pool f
runs f x
with x
a resource; when f
fails or returns, x
is returned to the pool for future reuse.