public class ConstantPoolStrategy extends java.lang.Object implements IPoolStrategy
Modifier and Type | Field and Description |
---|---|
protected int |
capacity
The number of free workers.
|
protected int |
workercnt
The number of workers in the pool.
|
Constructor and Description |
---|
ConstantPoolStrategy()
Create a new ConstantPoolStrategy.
|
ConstantPoolStrategy(int workercnt)
Create a new ConstantPoolStrategy.
|
Modifier and Type | Method and Description |
---|---|
int |
getCapacity()
Get the number of free workers.
|
int |
getWorkerCount()
Get the worker cnt.
|
long |
getWorkerTimeout()
Get the component timeout.
|
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.
|
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 component has occurred,
i.e.
|
protected int workercnt
protected int capacity
public ConstantPoolStrategy()
public ConstantPoolStrategy(int workercnt)
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 int getCapacity()
getCapacity
in interface IPoolStrategy