Resource Pool
(require data/pool) | package: resource-pool-lib |
This module provides a generic blocking resource pool implementation. Useful for managing things such as database and HTTP connections. Resource pools are both thread-safe and kill-safe.
procedure
v : any/c
procedure
(make-pool make-resource [ destroy-resource #:max-size max-size #:idle-ttl idle-ttl]) → pool? make-resource : (-> any/c) destroy-resource : (-> any/c void?) = void max-size : exact-positive-integer? = 8
idle-ttl : (or/c +inf.0 exact-positive-integer?) = (* 3600 1000)
The #:idle-ttl argument controls how long a resource can remain idle before destroy-resource is applied to it and it is removed from the pool.
procedure
(call-with-pool-resource p proc #:timeout timeout) → any/c p : pool? proc : (-> any/c any) timeout : (or/c #f exact-nonnegative-integer?)
The #:timeout behaves the same as in pool-take!, except that if the timeout is hit, an exn:fail:pool? is raised and #f is not executed.
procedure
(pool-take! p [timeout]) → (or/c #f any/c)
p : pool? timeout : (or/c #f exact-nonnegative-integer?) = #f
procedure
(pool-take!-evt p) → evt?
p : pool?
Added in version 0.3 of package resource-pool-lib.
procedure
(pool-release! p v) → void?
p : pool? v : any/c
procedure
(pool-close! p) → void?
p : pool?
Raises an exception if p has already been closed.
procedure
(exn:fail:pool? v) → boolean?
v : any/c