|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectgroovyx.gpars.scheduler.Scheduler
public final class Scheduler
Prototype of self-regulated thread pooled scheduler
Self regulation happened according to following rules - worker thread, which had nothing to do 10 seconds dies - if no tasks were taken for processing during last 0.5sec new worker starts
| Nested Class Summary | |
|---|---|
private class |
Scheduler.WatchdogThread
|
private class |
Scheduler.WorkerThread
|
| Field Summary | |
|---|---|
private long |
lastTaskPoke
|
private static long |
POKE_INTERVAL
|
private java.util.concurrent.BlockingQueue<java.lang.Runnable> |
queue
|
private long |
schedulerTime
|
(package private) static java.lang.RuntimeException |
TERMINATE
|
private boolean |
terminating
|
private java.util.concurrent.atomic.AtomicInteger |
threadCount
|
| Fields inherited from interface groovyx.gpars.scheduler.Pool |
|---|
POOL_SIZE_MUST_BE_A_POSITIVE_NUMBER, UNCAUGHT_EXCEPTION_OCCURRED_IN_ACTOR_POOL |
| Constructor Summary | |
|---|---|
Scheduler()
|
|
Scheduler(int coreSize)
|
|
| Method Summary | |
|---|---|
void |
execute(java.lang.Runnable task)
schedules a new task for processing with the pool |
int |
getPoolSize()
Retrieves the current thread pool size |
java.lang.Runnable |
loop(java.lang.Runnable operation)
|
void |
resetDefaultSize()
Sets the pool size to the default |
void |
resize(int poolSize)
Resizes the thread pool to the specified value |
void |
shutdown()
Gently stops the pool |
private void |
startNewThread()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final java.util.concurrent.BlockingQueue<java.lang.Runnable> queue
private final java.util.concurrent.atomic.AtomicInteger threadCount
private volatile long lastTaskPoke
private volatile long schedulerTime
private volatile boolean terminating
static final java.lang.RuntimeException TERMINATE
private static final long POKE_INTERVAL
| Constructor Detail |
|---|
public Scheduler()
public Scheduler(int coreSize)
| Method Detail |
|---|
public void execute(java.lang.Runnable task)
Pool
execute in interface Pooltask - The task to schedulepublic java.lang.Runnable loop(java.lang.Runnable operation)
private void startNewThread()
public void resize(int poolSize)
Pool
resize in interface PoolpoolSize - The new pool sizepublic void resetDefaultSize()
Pool
resetDefaultSize in interface Poolpublic int getPoolSize()
getPoolSize in interface Poolpublic void shutdown()
Pool
shutdown in interface Pool
|
Copyright © 2008–2012 Václav Pech. All Rights Reserved. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||