public class DefaultPoolStrategy extends java.lang.Object implements IPoolStrategy
Modifier and Type | Field and Description |
---|---|
protected int |
capacity
The number of free workers.
|
protected int |
deferdec
The defer factor to slow down thread deletion.
|
protected int |
deferdectarget |
protected int |
deferinc
The defer factor to slow down thread creation.
|
protected int |
deferinctarget |
protected int |
desfree
The desired number of free workers.
|
protected boolean |
dodeferdec
Defer the deletion of threads according to their distance from desfree.
|
protected boolean |
dodeferinc
Defer the creation of threads according to their distance from desfree.
|
protected int |
maxcnt
The maximum number of allowed workers.
|
protected long |
maxwait
The max wait time for workers.
|
protected java.util.List<java.lang.Double> |
waitings
The waiting times of the pool.
|
protected int |
workercnt
The number of workers in the pool.
|
Constructor and Description |
---|
DefaultPoolStrategy()
Create a new default pool strategy.
|
DefaultPoolStrategy(int desfree,
int maxcnt)
Create a new default pool strategy.
|
DefaultPoolStrategy(int workercnt,
int desfree,
long maxwait,
int maxcnt)
Create a new default pool strategy.
|
DefaultPoolStrategy(int workercnt,
int desfree,
long maxwait,
int maxcnt,
boolean defer)
Create a new default pool strategy.
|
DefaultPoolStrategy(int workercnt,
int desfree,
long maxwait,
int maxcnt,
boolean deferinc,
boolean deferdec)
Create a new default pool strategy.
|
DefaultPoolStrategy(int desfree,
long maxwait,
int maxcnt)
Create a new default pool strategy.
|
Modifier and Type | Method and Description |
---|---|
int |
getCapacity()
Get the capacity.
|
int |
getDesiredFree()
Get the desfree.
|
int |
getMaxCount()
Get the max cnt.
|
long |
getMaxWait()
Get the maxwait.
|
int |
getWorkerCount()
Get the worker cnt.
|
long |
getWorkerTimeout()
Get the worker timeout.
|
void |
setCapacity(int capacity)
Set the capacity.
|
void |
setDesiredFree(int desfree)
Set the desfree.
|
void |
setMaxCount(int maxcnt)
Set the max cnt.
|
void |
setMaxWait(long maxwait)
Set the maxwait.
|
void |
setWorkerCount(int workercnt)
Set the worker cnt.
|
boolean |
taskAdded()
Called when a new task was added to the pool.
|
boolean |
taskFinished()
Called when a task is finished.
|
void |
taskServed(long waitdur)
Called when a new task was served from the pool.
|
java.lang.String |
toString()
Get the string representation.
|
void |
workersAdded(int cnt)
Called when a new worker was added proactively to the pool.
|
boolean |
workerTimeoutOccurred()
Notify the strategy that a timeout for a worker has occurred,
i.e.
|
protected int workercnt
protected int capacity
protected int desfree
protected long maxwait
protected int maxcnt
protected boolean dodeferinc
protected boolean dodeferdec
protected int deferinc
protected int deferinctarget
protected int deferdec
protected int deferdectarget
protected java.util.List<java.lang.Double> waitings
public DefaultPoolStrategy()
public DefaultPoolStrategy(int desfree, int maxcnt)
public DefaultPoolStrategy(int desfree, long maxwait, int maxcnt)
public DefaultPoolStrategy(int workercnt, int desfree, long maxwait, int maxcnt)
public DefaultPoolStrategy(int workercnt, int desfree, long maxwait, int maxcnt, boolean defer)
public DefaultPoolStrategy(int workercnt, int desfree, long maxwait, int maxcnt, boolean deferinc, boolean deferdec)
public boolean taskAdded()
taskAdded
in interface IPoolStrategy
public void workersAdded(int cnt)
workersAdded
in interface IPoolStrategy
cnt
- The number of new workers.public void taskServed(long waitdur)
taskServed
in interface IPoolStrategy
waitdur
- The waiting time of the task.public boolean taskFinished()
taskFinished
in interface IPoolStrategy
public long getWorkerTimeout()
getWorkerTimeout
in interface IPoolStrategy
public boolean workerTimeoutOccurred()
workerTimeoutOccurred
in interface IPoolStrategy
public int getWorkerCount()
getWorkerCount
in interface IPoolStrategy
public void setWorkerCount(int workercnt)
workercnt
- The workercnt to set.public int getCapacity()
getCapacity
in interface IPoolStrategy
public void setCapacity(int capacity)
capacity
- The capacity to set.public int getDesiredFree()
public void setDesiredFree(int desfree)
desfree
- The desfree to set.public long getMaxWait()
public void setMaxWait(long maxwait)
maxwait
- The maxwait to set.public int getMaxCount()
public void setMaxCount(int maxcnt)
maxservicecnt
- The max cnt to set.public java.lang.String toString()
toString
in class java.lang.Object