Liking cljdoc? Tell your friends :D

riemann.pool

A generic thread-safe resource pool.

A generic thread-safe resource pool.
raw docstring

fixed-poolclj

(fixed-pool open)
(fixed-pool open opts)
(fixed-pool open close opts)

A fixed pool of thingys. (open) is called to generate a thingy. (close thingy) is called when a thingy is invalidated. When thingys are invalidated, the pool will immediately try to open a new one; if open throws or returns nil, the pool will sleep for regenerate-interval seconds before retrying (open).

  • :regenerate-interval How long to wait between retrying (open).
  • :size Number of thingys in the pool.
  • :block-start Should (fixed-pool) wait until the pool is full before returning?

Note that fixed-pool is correct only if every successful (claim) is followed by exactly one of either (invalidate) or (release). If calls are unbalanced; e.g. resources are not released, doubly released, or released and invalidated, starvation or unbounded blocking could occur. (with-pool) provides this guarantee.

A fixed pool of thingys. (open) is called to generate a thingy. (close
thingy) is called when a thingy is invalidated. When thingys are invalidated,
the pool will immediately try to open a new one; if open throws or returns
nil, the pool will sleep for regenerate-interval seconds before retrying
(open).

- :regenerate-interval    How long to wait between retrying (open).
- :size                   Number of thingys in the pool.
- :block-start            Should (fixed-pool) wait until the pool is full
                          before returning?

Note that fixed-pool is correct only if every successful (claim) is followed
by exactly one of either (invalidate) or (release). If calls are unbalanced;
e.g. resources are not released, doubly released, or released *and*
invalidated, starvation or unbounded blocking could occur. (with-pool)
provides this guarantee.
sourceraw docstring

Poolcljprotocol

claimclj

(claim pool)
(claim pool timeout)

Take a thingy from the pool. Timeout in seconds; if unspecified, 0. Returns nil if no thingy available.

Take a thingy from the pool. Timeout in seconds; if unspecified, 0.
Returns nil if no thingy available.

growclj

(grow pool)

Adds an element to the pool.

Adds an element to the pool.

invalidateclj

(invalidate pool thingy)

Tell the pool a thingy is no longer valid.

Tell the pool a thingy is no longer valid.

releaseclj

(release pool thingy)

Returns a thingy to the pool.

Returns a thingy to the pool.
source

with-poolcljmacro

(with-pool [thingy pool timeout] & body)

Evaluates body in a try expression with a symbol 'thingy claimed from the given pool, with specified claim timeout. Releases thingy at the end of the body, or if an exception is thrown, invalidates them and rethrows. Example:

; With client, taken from connection-pool, waiting 5 seconds to claim, send
; client a message.
(with-pool [client connection-pool 5]
  (send client a-message))
Evaluates body in a try expression with a symbol 'thingy claimed from the
given pool, with specified claim timeout. Releases thingy at the end of the
body, or if an exception is thrown, invalidates them and rethrows. Example:

```clojure
; With client, taken from connection-pool, waiting 5 seconds to claim, send
; client a message.
(with-pool [client connection-pool 5]
  (send client a-message))
```
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close