Skip to content

Commit 094ebf4

Browse files
authored
Update README.md
1 parent 5b63496 commit 094ebf4

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,31 @@
11
# ObjectPool
2-
LIbrary to pool any objects
2+
Object Pool offers easy way to build pools for objects. One common situation
3+
could be pooling database connections. This library was created for supporting pooling
4+
of GlorpDBX database connections. However GlorpDBX related code is different
5+
package.
6+
7+
Objects borrowed from OPPool have following basic lifecycle:
8+
9+
1. Objects are first created.
10+
2. When objects are borrowed from pool they are activated..
11+
3. When objects are returned to pool they are passivated.
12+
4. When objects is no longer usable (some lifecycle operation fails) or needed it is destroyed.
13+
14+
To create pool for of OrderedCollections one could write:
15+
OPBasicPool new
16+
creator: [OrderedCollection new].
17+
18+
To get new collection from the pool:
19+
pool withPooled: [:o| "Do something"].
20+
21+
To also clear collections when they are returned add passivator
22+
pool passivator:[:o|o removeAll].
23+
24+
Or to do that before borrow add activator:
25+
pool activator:[:o|o removeAll].
26+
27+
To validate objets before borrow add following. Objects that do not validate are destroyed.
28+
pool validator:[:o|o size = 0].
29+
30+
One can set maximum size of pool with #maxIdleIbjects. See more about pool configuration
31+
in documentation of OPBasicPool.

0 commit comments

Comments
 (0)