public class StormTimer extends Object implements AutoCloseable
Modifier and Type | Class and Description |
---|---|
static class |
StormTimer.QueueEntry |
static class |
StormTimer.StormTimerTask |
Constructor and Description |
---|
StormTimer(String name,
Thread.UncaughtExceptionHandler onKill)
Makes a Timer in the form of a StormTimerTask Object.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
cancel timer.
|
boolean |
isTimerWaiting()
is timer waiting.
|
void |
schedule(int delaySecs,
Runnable func) |
void |
schedule(int delaySecs,
Runnable func,
boolean checkActive,
int jitterMs)
Schedule a function to be executed in the timer.
|
void |
scheduleMs(long delayMs,
Runnable func) |
void |
scheduleMs(long delayMs,
Runnable func,
boolean checkActive,
int jitterMs)
Same as schedule with millisecond resolution.
|
void |
scheduleRecurring(int delaySecs,
int recurSecs,
Runnable func)
Schedule a function to run recurrently.
|
void |
scheduleRecurringMs(long delayMs,
long recurMs,
Runnable func)
Schedule a function to run recurrently.
|
void |
scheduleRecurringWithJitter(int delaySecs,
int recurSecs,
int jitterMs,
Runnable func)
Schedule a function to run recurrently with jitter.
|
public StormTimer(String name, Thread.UncaughtExceptionHandler onKill)
name
- name of the timeronKill
- function to call when timer is killed unexpectedlypublic void schedule(int delaySecs, Runnable func, boolean checkActive, int jitterMs)
delaySecs
- the number of seconds to delay before running the functionfunc
- the function to runcheckActive
- whether to check is the timer is activejitterMs
- add jitter to the runpublic void schedule(int delaySecs, Runnable func)
public void scheduleMs(long delayMs, Runnable func, boolean checkActive, int jitterMs)
delayMs
- the number of milliseconds to delay before running the functionfunc
- the function to runcheckActive
- whether to check is the timer is activejitterMs
- add jitter to the runpublic void scheduleMs(long delayMs, Runnable func)
public void scheduleRecurring(int delaySecs, int recurSecs, Runnable func)
delaySecs
- the number of seconds to delay before running the functionrecurSecs
- the time between each invocationfunc
- the function to runpublic void scheduleRecurringMs(long delayMs, long recurMs, Runnable func)
delayMs
- the number of millis to delay before running the functionrecurMs
- the time between each invocationfunc
- the function to runpublic void scheduleRecurringWithJitter(int delaySecs, int recurSecs, int jitterMs, Runnable func)
delaySecs
- the number of seconds to delay before running the functionrecurSecs
- the time between each invocationjitterMs
- jitter added to the runfunc
- the function to runpublic void close() throws InterruptedException
close
in interface AutoCloseable
InterruptedException
public boolean isTimerWaiting()
Copyright © 2023 The Apache Software Foundation. All rights reserved.