|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jgroups.util.HashedTimingWheel
public class HashedTimingWheel
Implementation of TimeScheduler. Uses a hashed timing wheel [1].
[1] http://www.cse.wustl.edu/~cdgill/courses/cs6874/TimingWheels.ppt
| Nested Class Summary | |
|---|---|
protected static class |
HashedTimingWheel.MyTask
Simple task wrapper, always executed by at most 1 thread. |
| Nested classes/interfaces inherited from interface org.jgroups.util.TimeScheduler |
|---|
TimeScheduler.Task |
| Field Summary | |
|---|---|
protected static Log |
log
|
protected long |
ROTATION_TIME
|
protected boolean |
running
|
protected long |
tick_time
|
protected ThreadFactory |
timer_thread_factory
|
protected java.util.List<HashedTimingWheel.MyTask>[] |
wheel
|
protected int |
wheel_position
|
protected int |
wheel_size
|
| Constructor Summary | |
|---|---|
HashedTimingWheel()
Create a scheduler that executes tasks in dynamically adjustable intervals |
|
HashedTimingWheel(int corePoolSize)
|
|
HashedTimingWheel(ThreadFactory factory,
int min_threads,
int max_threads,
long keep_alive_time,
int max_queue_size,
int wheel_size,
long tick_time)
|
|
| Method Summary | |
|---|---|
protected void |
_run()
|
java.lang.String |
dumpTimerTasks()
Returns a list of tasks currently waiting for execution. |
void |
execute(java.lang.Runnable task)
Executes command with zero required delay. |
int |
getCurrentThreads()
Returns the current threads in the pool, or -1 if not applicable |
long |
getKeepAliveTime()
Returns the keep alive time (in ms) of the thread pool, or -1 if not applicable |
int |
getMaxThreads()
Returns the configured max threads, or -1 if not applicable |
int |
getMinThreads()
Returns the configured core threads, or -1 if not applicable |
int |
getQueueSize()
|
protected void |
init()
|
boolean |
isShutdown()
Returns true if stop() has been called, false otherwise |
void |
run()
|
java.util.concurrent.Future<?> |
schedule(java.lang.Runnable work,
long delay,
java.util.concurrent.TimeUnit unit)
Creates and executes a one-shot action that becomes enabled after the given delay. |
java.util.concurrent.Future<?> |
scheduleAtFixedRate(java.lang.Runnable task,
long initial_delay,
long delay,
java.util.concurrent.TimeUnit unit)
Creates and executes a periodic action that becomes enabled first after the given initial delay, and subsequently with the given period; that is executions will commence after initialDelay then initialDelay+period, then initialDelay + 2 * period, and so on. |
java.util.concurrent.Future<?> |
scheduleWithDynamicInterval(TimeScheduler.Task task)
Schedule a task for execution at varying intervals. |
java.util.concurrent.Future<?> |
scheduleWithFixedDelay(java.lang.Runnable task,
long initial_delay,
long delay,
java.util.concurrent.TimeUnit unit)
Creates and executes a periodic action that becomes enabled first after the given initial delay, and subsequently with the given delay between the termination of one execution and the commencement of the next. |
void |
setKeepAliveTime(long time)
Sets the keep alive time (in ms) of the thread pool. |
void |
setMaxThreads(int size)
Sets the max pool size. |
void |
setMinThreads(int size)
Sets the core pool size. |
void |
setThreadFactory(ThreadFactory factory)
|
int |
size()
Returns the number of tasks currently in the timer |
protected void |
startRunner()
|
void |
stop()
Stops the timer, cancelling all tasks |
protected void |
stopRunner()
|
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected volatile boolean running
protected static final Log log
protected ThreadFactory timer_thread_factory
protected int wheel_size
protected long tick_time
protected final long ROTATION_TIME
protected final java.util.List<HashedTimingWheel.MyTask>[] wheel
protected int wheel_position
| Constructor Detail |
|---|
public HashedTimingWheel()
public HashedTimingWheel(ThreadFactory factory,
int min_threads,
int max_threads,
long keep_alive_time,
int max_queue_size,
int wheel_size,
long tick_time)
public HashedTimingWheel(int corePoolSize)
| Method Detail |
|---|
public void setThreadFactory(ThreadFactory factory)
setThreadFactory in interface TimeSchedulerpublic int getMinThreads()
TimeScheduler
getMinThreads in interface TimeSchedulerpublic void setMinThreads(int size)
TimeScheduler
setMinThreads in interface TimeSchedulerpublic int getMaxThreads()
TimeScheduler
getMaxThreads in interface TimeSchedulerpublic void setMaxThreads(int size)
TimeScheduler
setMaxThreads in interface TimeSchedulerpublic long getKeepAliveTime()
TimeScheduler
getKeepAliveTime in interface TimeSchedulerpublic void setKeepAliveTime(long time)
TimeScheduler
setKeepAliveTime in interface TimeSchedulerpublic int getCurrentThreads()
TimeScheduler
getCurrentThreads in interface TimeSchedulerpublic int getQueueSize()
public java.lang.String dumpTimerTasks()
TimeScheduler
dumpTimerTasks in interface TimeSchedulerpublic void execute(java.lang.Runnable task)
TimeScheduler
execute in interface TimeSchedulertask - the task to execute
public java.util.concurrent.Future<?> schedule(java.lang.Runnable work,
long delay,
java.util.concurrent.TimeUnit unit)
TimeScheduler
schedule in interface TimeSchedulerwork - the task to executedelay - the time from now to delay executionunit - the time unit of the delay parameter
public java.util.concurrent.Future<?> scheduleWithFixedDelay(java.lang.Runnable task,
long initial_delay,
long delay,
java.util.concurrent.TimeUnit unit)
TimeScheduler
scheduleWithFixedDelay in interface TimeSchedulertask - the task to executeinitial_delay - the time to delay first executiondelay - the delay between the termination of one execution and the commencement of the nextunit - the time unit of the initialDelay and delay parameters
public java.util.concurrent.Future<?> scheduleAtFixedRate(java.lang.Runnable task,
long initial_delay,
long delay,
java.util.concurrent.TimeUnit unit)
TimeScheduler
scheduleAtFixedRate in interface TimeSchedulertask - the task to executeinitial_delay - the time to delay first executiondelay - the period between successive executionsunit - the time unit of the initialDelay and period parameters
public java.util.concurrent.Future<?> scheduleWithDynamicInterval(TimeScheduler.Task task)
org.jgroups.util.HashedTimingWheel.Task#nextInterval() milliseconds. The task is neve done until nextInterval()
return a value <= 0 or the task is cancelled.
scheduleWithDynamicInterval in interface TimeSchedulertask - the task to execute
Task is rescheduled relative to the last time it actually started execution
false:public int size()
size in interface TimeSchedulerpublic java.lang.String toString()
toString in class java.lang.Objectpublic void stop()
stop in interface TimeSchedulerjava.lang.InterruptedException - if interrupted while waiting for thread to returnpublic boolean isShutdown()
TimeScheduler
isShutdown in interface TimeSchedulerpublic void run()
run in interface java.lang.Runnableprotected void _run()
protected void init()
protected void startRunner()
protected void stopRunner()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||