Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the pooler Reference Manual, version 1.0.0, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Dec 22 14:42:16 2020 GMT+0.
• Introduction | What pooler is all about | |
• Systems | The systems documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
A Trivial, Fast, Thread-Safe Pooling Library for Common Lisp.
We need pools for items which have heavy cost of creation and which we can reuse. A typical use case is connection pools.
Pool item creation (as required) is automatic on fetch-from pool. Pool-item's are created and destroyed using user supplied funcitons. The pool has a idle timeout after which all the existing pool-item's are destroyed and new ones created (pool-init). The pool has a threshold number of items which it tries to maintain.
Licence : MIT
Structure POOL
NAME : Is a text string identifying the POOL
QUEUE : A queue to store the POOL-ITEMs
POOL-LOCK : A lock we hold when we want to update the POOL
ITEM-MAKER : A function which returns a POOL-ITEM.
ITEM-DESTROYER : A function which sanely destroys a POOL-ITEM
CAPACITY : The max number of POOL-ITEMs to store in the POOL
THRESHOLD : The min number of POOL-ITEMs we should ideally keep in the POOL.
TIMEOUT : The number of seconds of idleness after which the POOL will be re-init.
LAST-ACCESS : The last access time for the POOL.
CURRENT-SIZE : The current number of POOL-ITEMs in the POOL
TOTAL-USES : Total number of times the POOL-ITEMs have been taken out of the POOL
TOTAL-CREATED : Total number of new POOL-ITEMs created and added to the POOL
TOTAL-POOL-INITS : How many times the POOL was 'INIT'.
make-pool &key name max-capacity min-threshold pool-item-maker pool-item-destroyer
Makes and returns a new POOL.
grow-pool pool &optional grow-by
Creates and adds POOL-ITEMs to the pool. In case grow-by is not provided then it takes ( threshold pool ) as the value
fetch-from-aux pool
Fetches a POOL-ITEM from the POOL. Tell us if the pool has become old.
fetch-from pool &key (tries 3)
Is a wrapper around fetch-from-aux and will try tries number of times to fetch POOL-ITEM from POOL. In case POOL-ITEM is not returned then it grows the POOL and tries again.
return-to pool pool-item
Returns a POOL-ITEM to the POOL. In case the pool is at CAPACITY the POOL-ITEM will be sanely destroyed using the given function
pool-init pool
Sanely destroys all the POOL-ITEMS and then re-creates THRESHOLD number of POOL-ITEMS.
with-pool pool-item pool &body body
Executes the body where pool-item is fetched from the pool and available. Sanely returns pool-item to the pool on finish of body.
POOLER> (defvar *x* nil)
*X*
POOLER> (setf *x* (make-pool :name "Test Pool"))
#<POOL Test Pool Max:4 Current:0 >
POOLER> (fetch-from+ *x*)
SAMPLE-ITEM
POOLER> *x*
#<POOL Test Pool Max:4 Current:1 >
POOLER> (return-to *x* **)
2
POOLER> (with-pool (pool-item *x*) (print pool-item))
SAMPLE-ITEM
SAMPLE-ITEM
POOLER> *x*
#<POOL Test Pool Max:4 Current:2 >
Another
CL-USER> (pooler:make-pool :item-maker #'(lambda () (clsql:connect '("127.0.0.1" "quasidb" "quasi" "*****")
:database-type :mysql
:if-exists :new))
:item-destroyer #'(lambda (item) (clsql:disconnect :database item)))
#S(POOLER::POOL
:NAME "Default Pool"
:QUEUE #S(SB-CONCURRENCY:QUEUE
:HEAD (SB-CONCURRENCY::.DUMMY.)
:TAIL (SB-CONCURRENCY::.DUMMY.)
:NAME NIL)
:LOCK #<SB-THREAD:MUTEX "Pool Lock" (free)>
:ITEM-MAKER #<FUNCTION (LAMBDA #) {1005C9BFAB}>
:ITEM-DESTROYER #<FUNCTION (LAMBDA #) {1005CCAAAB}>
:CAPACITY 40
:THRESHOLD 2
:TIMEOUT 300
:LAST-ACCESS 0
:CURRENT-SIZE 0
:TOTAL-USES 0
:TOTAL-CREATED 0
:TOTAL-POOL-INITS 0)
CL-USER> (defvar *mysql-pool* *)
CL-USER> (pooler:fetch-from *mysql-pool*)
#<CLSQL-MYSQL:MYSQL-DATABASE 127.0.0.1/quasidb/quasi OPEN {1007571373}>
CL-USER> (pooler:return-to *mysql-pool* *)
2
CL-USER> (pooler:with-pool (db *mysql-pool*) (clsql:query "show tables;" :database db))
(("LOGIN_DATA"))
("Tables_in_quasidb")
Abhijit Rao a.k.a quasi
quasi@quasilabs.in
Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The pooler system |
quasi <quasi@quasilabs.in>
MIT
Generic thread-safe pooling facility for your library.
A Trivial, Fast & Thread-Safe Pooling Library for Common Lisp.
We need pools for items which have heavy cost of creation and which we can reuse.
A typical use case is connection pools.
Pool item creation (as required) is automatic on fetch-from pool. Pool-item’s are created and destroyed using user supplied funcitons. The pool has a idle timeout after which all the existing pool-item’s are destroyed and new ones created (pool-init). The pool has a threshold number of items which it tries to maintain.
1.0.0
sb-concurrency
pooler.asd (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
• The pooler.asd file | ||
• The pooler/package.lisp file | ||
• The pooler/utils.lisp file | ||
• The pooler/pooler.lisp file |
Next: The pooler/package․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
pooler.asd
pooler (system)
Next: The pooler/utils․lisp file, Previous: The pooler․asd file, Up: Lisp files [Contents][Index]
Next: The pooler/pooler․lisp file, Previous: The pooler/package․lisp file, Up: Lisp files [Contents][Index]
package.lisp (file)
pooler (system)
utils.lisp
Previous: The pooler/utils․lisp file, Up: Lisp files [Contents][Index]
utils.lisp (file)
pooler (system)
pooler.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The pooler package |
package.lisp (file)
common-lisp
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported macros | ||
• Exported functions |
Next: Exported functions, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
pooler.lisp (file)
Previous: Exported macros, Up: Exported definitions [Contents][Index]
Tries a couple of times to fetch from pool. Grows the pool.
pooler.lisp (file)
pooler.lisp (file)
pooler.lisp (file)
Cleans up the pool & reinits it with MIN-THRESHOLD number of POOL-ITEM
pooler.lisp (file)
Returns a pool object to the pool
pooler.lisp (file)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal macros | ||
• Internal functions | ||
• Internal generic functions | ||
• Internal conditions | ||
• Internal structures |
Next: Internal functions, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
utils.lisp (file)
utils.lisp (file)
utils.lisp (file)
utils.lisp (file)
Next: Internal generic functions, Previous: Internal macros, Up: Internal definitions [Contents][Index]
pooler.lisp (file)
utils.lisp (file)
Destroys the POOL-ITEM using the item-destroyer funciton stored in the pool
pooler.lisp (file)
Are there no elements in the queue?
utils.lisp (file)
Add a list of items to the end of the queue.
utils.lisp (file)
Fetches a pool item from pool.
pooler.lisp (file)
utils.lisp (file)
utils.lisp (file)
utils.lisp (file)
utils.lisp (file)
Creates a new POOL-ITEM using the item-maker funciton stored in the pool
pooler.lisp (file)
pooler.lisp (file)
pooler.lisp (file)
Signals an error of type POOL-ERROR with the provided information
pooler.lisp (file)
pooler.lisp (file)
pooler.lisp (file)
pooler.lisp (file)
pooler.lisp (file)
pooler.lisp (file)
pooler.lisp (file)
pooler.lisp (file)
pooler.lisp (file)
pooler.lisp (file)
pooler.lisp (file)
pooler.lisp (file)
pooler.lisp (file)
utils.lisp (file)
utils.lisp (file)
utils.lisp (file)
utils.lisp (file)
Return the element at the front of the queue.
utils.lisp (file)
Remove the element from the front of the queue and return it.
utils.lisp (file)
Next: Internal conditions, Previous: Internal functions, Up: Internal definitions [Contents][Index]
pooler.lisp (file)
pooler.lisp (file)
pooler.lisp (file)
Next: Internal structures, Previous: Internal generic functions, Up: Internal definitions [Contents][Index]
pooler.lisp (file)
pool-error (condition)
Superclass for all errors related to Pooler.
pooler.lisp (file)
error (condition)
:message
(quote nil)
message (generic function)
(setf message) (generic function)
:name
(quote nil)
name (generic function)
(setf name) (generic function)
pooler.lisp (file)
pool-error (condition)
pooler.lisp (file)
warning (condition)
:message
(quote nil)
message (generic function)
(setf message) (generic function)
Previous: Internal conditions, Up: Internal definitions [Contents][Index]
pooler.lisp (file)
structure-object (structure)
simple-string
"default pool"
pool-name (function)
(setf pool-name) (function)
(pooler::make-queue)
pool-queue (function)
(setf pool-queue) (function)
(pooler::make-pool-lock)
pool-lock (function)
(setf pool-lock) (function)
function
(function (lambda nil (quote pooler::sample-item)))
pool-item-maker (function)
(setf pool-item-maker) (function)
function
(function (lambda (pooler::item) (setf pooler::item nil)))
pool-item-destroyer (function)
(setf pool-item-destroyer) (function)
fixnum
40
pool-capacity (function)
(setf pool-capacity) (function)
fixnum
2
pool-threshold (function)
(setf pool-threshold) (function)
fixnum
300
pool-timeout (function)
(setf pool-timeout) (function)
integer
0
pool-last-access (function)
(setf pool-last-access) (function)
fixnum
0
pool-current-size (function)
(setf pool-current-size) (function)
fixnum
0
pool-total-uses (function)
(setf pool-total-uses) (function)
fixnum
0
pool-total-created (function)
(setf pool-total-created) (function)
fixnum
0
pool-total-pool-inits (function)
(setf pool-total-pool-inits) (function)
utils.lisp (file)
structure-object (structure)
(function identity)
q-key (function)
(setf q-key) (function)
q-last (function)
(setf q-last) (function)
q-elements (function)
(setf q-elements) (function)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | F L P |
---|
Jump to: | F L P |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | (
C D E F G M N P Q R W |
---|
Jump to: | (
C D E F G M N P Q R W |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | C E I K L M N Q S T |
---|
Jump to: | C E I K L M N Q S T |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | C P Q S |
---|
Jump to: | C P Q S |
---|