public class SweeperPool extends Object
Constructor and Description |
---|
SweeperPool(int maxSize,
int minSize,
int intialCapacity,
int sweepInterval,
int triggerSize)
There are a number of settings to control how the pool operates.
|
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Dispose of this pool.
|
Object |
get()
Return the pooled object
|
int |
getSize()
Return the number of pooled objects.
|
void |
objectAdded(Object obj)
Override this to be notified of object addition.
|
void |
objectDisposed(Object obj)
Override this to be notified of object disposal.
|
void |
objectRetrieved(Object obj)
Override this to be notified of object retrieval.
|
boolean |
put(Object obj)
Add an object to the pool
|
void |
trim()
Trim the pool down to min size
|
public SweeperPool(int maxSize, int minSize, int intialCapacity, int sweepInterval, int triggerSize)
There are a number of settings to control how the pool operates.
minSize
- this is the size the pool is trimmed totriggerSize
- this determines if the pool is trimmed when
the sweeper runs. If the pool size is greater or equal than this value then
the pool is trimmed to minSize
.
maxSize
- if the pool has reached this size, any objects added
are immediatley disposed. If the pool is this size when the sweeper runs, then
the pool is also trimmed to minSize
irrespective of the triggerSize.
sweepInterval
- how often the sweeper runs. Is actually the
time since the sweeper last finished a pass. 0 if the sweeper should not run.
Any value less than 0 is automatically converted to 0
public Object get()
public boolean put(Object obj)
obj
- the object to pool. Can be null.public int getSize()
public void dispose()
public void trim()
public void objectDisposed(Object obj)
obj
- public void objectAdded(Object obj)
obj
- public void objectRetrieved(Object obj)
obj
- Copyright © 2001-2014 Codehaus. All Rights Reserved.