@InterfaceAudience.Private public abstract class Chore extends HasThread
Don't subclass Chore if the task relies on being woken up for something to do, such as an entry being added to a queue, etc.
Modifier | Constructor and Description |
---|---|
protected |
Chore()
This constructor is for test only.
|
|
Chore(String name,
int p,
Stoppable stopper) |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
chore()
Look for chores.
|
void |
choreForTesting() |
protected void |
cleanup()
Called when the chore has completed, allowing subclasses to cleanup any
extra overhead
|
protected boolean |
initialChore()
Override to run a task before we start looping.
|
void |
run() |
protected void |
sleep()
Sleep for period.
|
void |
triggerNow()
If the thread is currently sleeping, trigger the core to happen immediately.
|
getName, getThread, interrupt, isAlive, isInterrupted, join, join, join, setDaemon, setName, setPriority, setUncaughtExceptionHandler, start
protected final Stoppable stopper
public Chore(String name, int p, Stoppable stopper)
p
- Period at which we should run. Will be adjusted appropriately
should we find work and it takes time to complete.stopper
- When Stoppable.isStopped()
is true, this thread will
cleanup and exit cleanly.protected Chore()
public void run()
run
in interface Runnable
run
in class HasThread
Thread.run()
public void triggerNow()
public void choreForTesting()
protected boolean initialChore()
protected abstract void chore()
protected void sleep()
protected void cleanup()
Copyright © 2013 The Apache Software Foundation. All Rights Reserved.