File tree 1 file changed +16
-11
lines changed
1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -12,20 +12,25 @@ Objects borrowed from OPPool have following basic lifecycle:
12
12
4 . When objects is no longer usable (some lifecycle operation fails) or needed it is destroyed.
13
13
14
14
To create pool for of OrderedCollections one could write:
15
- OPBasicPool new
16
- creator: [ OrderedCollection new] .
17
-
15
+ ``` Smalltalk
16
+ OPBasicPool new
17
+ creator: [OrderedCollection new].
18
+ ```
18
19
To get new collection from the pool:
19
- pool withPooled: [ : o | "Do something"] .
20
-
20
+ ``` Smalltalk
21
+ pool withPooled: [:o| "Do something"].
22
+ ```
21
23
To also clear collections when they are returned add passivator
22
- pool passivator:[ : o |o removeAll] .
23
-
24
+ ``` Smalltalk
25
+ pool passivator:[:o|o removeAll].
26
+ ```
24
27
Or to do that before borrow add activator:
25
- pool activator:[ : o |o removeAll] .
26
-
28
+ ``` Smalltalk
29
+ pool activator:[:o|o removeAll].
30
+ ```
27
31
To validate objets before borrow add following. Objects that do not validate are destroyed.
28
- pool validator:[ : o |o size = 0] .
29
-
32
+ ``` Smalltalk
33
+ pool validator:[:o|o size = 0].
34
+ ```
30
35
One can set maximum size of pool with #maxIdleIbjects. See more about pool configuration
31
36
in documentation of OPBasicPool.
You can’t perform that action at this time.
0 commit comments