Liking cljdoc? Tell your friends :D

kafka-clj.pool.atom

Object pool using Sempahore and Clojure's atom

Use create-atom-obj-pool to create an atom object pool These functions as made to be used primarily from the kafka-clj.pool.keyed namespace and the kafka-clj.pool.api is used to work with the keyed pool

Object pool using Sempahore and Clojure's atom

Use create-atom-obj-pool to create an atom object pool
These functions as made to be used primarily from the kafka-clj.pool.keyed namespace
and the kafka-clj.pool.api is used to work with the keyed pool
raw docstring

a-available?clj

(a-available? {:keys [sem]})

Number of objects available in the atom pool

Number of objects available in the atom pool
raw docstring

a-destroyclj

(a-destroy {:keys [destroy-f sem ctx]} v)

Run (destroy-f ctx v) and will always release a permit on the semaphore even if destroy-f throws an exception This function does not check if v was attained from the pool, this is the responsibility of the calling program

Note: destroy-f is only called if (pool-obj-val v) is non nil

Run (destroy-f ctx v) and will always release a permit on the semaphore even if destroy-f throws an exception
This function does not check if v was attained from the pool, this is the responsibility of the calling program

Note: destroy-f is only called if (pool-obj-val v) is non nil
raw docstring

a-destroy-idle-timeouts!clj

(a-destroy-idle-timeouts! pool timeout-ms)

a-destroy-timeouts!clj

(a-destroy-timeouts! {:keys [queue closed-atom] :as pool}
                     should-destroy?
                     timeout-ms)

Destroy pool objects timeout

Destroy pool objects timeout
raw docstring

a-destroy-ttl-timeouts!clj

(a-destroy-ttl-timeouts! pool timeout-ms)

a-pollclj

(a-poll {:keys [ctx queue create-f sem closed-atom]} timeout-ms)

arg: AtomPool return a PoolObj

arg: AtomPool
return a PoolObj
raw docstring

a-poll-check-or-createclj

(a-poll-check-or-create ctx x create-f)

If x is nil we call create-f in a delay. returns a delayed object, this function runs inside swap! so needs to be idempotent

If x is nil we call create-f in a delay.
returns a delayed object, this function runs inside swap! so needs to be idempotent
raw docstring

a-poll-validclj

(a-poll-valid pool timeout-ms)

Poll for a valid object, invalid objects are destroyed, this process is repeated till a valid object is found or timeout-ms have expired

Note: validate-f is only called if (pool-obj-val v) is non nil

Poll for a valid object, invalid objects are destroyed, this process is repeated till a valid object is found
or timeout-ms have expired

Note: validate-f is only called if (pool-obj-val v) is non nil

raw docstring

a-poolclj

(a-pool ctx create-f validate-f destroy-f)

create-f when called should create a valid object called as (create-f ctx), validate-f is called before poll returns, called (validate-f ctx v) destroy-f is called to destroy an object (destroy-f ctx v) sem is a semaphore setting up the limit = (get ctx :pool-limit 20)

create-f when called should create a valid object called as (create-f ctx),
validate-f is called before poll returns, called (validate-f ctx v)
destroy-f  is called to destroy an object (destroy-f ctx v)
sem is a semaphore setting up the limit = (get ctx :pool-limit 20)
raw docstring

a-pool-close-allclj

(a-pool-close-all {:keys [queue closed-atom] :as pool})

a-pool-statsclj

(a-pool-stats pool)

Return a map {:available <available objs> :waiting-threads <threads waiting to acquire an obj>}

Return a map {:available <available objs> :waiting-threads <threads waiting to acquire an obj>}
raw docstring

a-returnclj

(a-return {:keys [queue sem]} v)

We add v back into the pool, and do not change the head v must be an instance of PoolObj

We add v back into the pool, and do not change the head
v must be an instance of PoolObj
raw docstring

a-validate-safelyclj

(a-validate-safely {:keys [ctx validate-f]} v)

Call validate in a try catch, if any exception nil is returned

Call validate in a try catch, if any exception nil is returned
raw docstring

a-waiting-threadsclj

(a-waiting-threads {:keys [sem]})

Returns an estimate of the number of threads waiting to acquire

Returns an estimate of the number of threads waiting to acquire
raw docstring

atom-closed?clj

(atom-closed? closed)

atom-get-and-set!clj

(atom-get-and-set! closed)

create-atom-obj-poolclj

(create-atom-obj-pool ctx create-f validate-f destroy-f)

destroy-all-objs!clj

(destroy-all-objs! pool objs)

Get timedout objecs from any idle objects and call destroy on them, this is a NOOP if the pool is closed

Get timedout objecs from any idle objects and call destroy on them, this is a NOOP if the pool is closed
raw docstring

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

× close