org.apache.batik.util
public class RunnableQueue extends Object implements Runnable
Nested Class Summary | |
---|---|
interface | RunnableQueue.IdleRunnable
A {@link Runnable} that can also inform the caller how long it should
be until it is run again. |
protected static class | RunnableQueue.Link
To store a Runnable. |
protected static class | RunnableQueue.LockableLink
To store a Runnable with an object waiting for him to be executed. |
interface | RunnableQueue.RunHandler
This interface must be implemented by an object which wants to
be notified of run events. |
static class | RunnableQueue.RunHandlerAdapter
This is an adapter class that implements the RunHandler interface.
|
static class | RunnableQueue.RunnableQueueState
Type-safe enumeration of queue states. |
Field Summary | |
---|---|
protected int | preemptCount
Count of preempt entries in queue, so preempt entries
can be kept properly ordered. |
protected RunnableQueue.RunHandler | runHandler
The object which handle run events. |
protected HaltingThread | runnableQueueThread
The current thread. |
static RunnableQueue.RunnableQueueState | RUNNING
The queue is in the process of running tasks. |
protected RunnableQueue.RunnableQueueState | state
The Suspension state of this thread. |
protected Object | stateLock
Object to synchronize/wait/notify for suspension
issues. |
static RunnableQueue.RunnableQueueState | SUSPENDED
The queue is no longer running any tasks and will not
run any tasks until resumeExecution is called. |
static RunnableQueue.RunnableQueueState | SUSPENDING
The queue may still be running tasks but as soon as possible
will go to SUSPENDED state. |
protected boolean | wasResumed
Used to indicate if the queue was resumed while
still running, so a 'resumed' event can be sent. |
Method Summary | |
---|---|
static RunnableQueue | createRunnableQueue()
Creates a new RunnableQueue started in a new thread. |
protected void | executionResumed()
Called when execution is being resumed.
|
protected void | executionSuspended()
Called when execution is being suspended.
|
Object | getIteratorLock()
Returns iterator lock to use to work with the iterator
returned by iterator(). |
RunnableQueue.RunnableQueueState | getQueueState() |
RunnableQueue.RunHandler | getRunHandler()
Returns the RunHandler or null. |
HaltingThread | getThread()
Returns the thread in which the RunnableQueue is currently running. |
void | invokeAndWait(Runnable r)
Waits until the given Runnable's run() has returned.
|
void | invokeLater(Runnable r)
Schedules the given Runnable object for a later invocation, and
returns.
|
Iterator | iterator()
Returns an iterator over the runnables. |
void | preemptAndWait(Runnable r)
Waits until the given Runnable's run() has returned.
|
void | preemptLater(Runnable r)
Schedules the given Runnable object for a later invocation, and
returns. |
void | resumeExecution()
Resumes the execution of this queue. |
void | run()
Runs this queue. |
protected void | runnableInvoked(Runnable rable)
Called when a Runnable completes.
|
protected void | runnableStart(Runnable rable)
Called just prior to executing a Runnable.
|
void | setIdleRunnable(RunnableQueue.IdleRunnable r)
Sets a Runnable to be run whenever the queue is empty. |
void | setRunHandler(RunnableQueue.RunHandler rh)
Sets the RunHandler for this queue. |
void | suspendExecution(boolean waitTillSuspended)
Suspends the execution of this queue after the current runnable
completes. |
Returns: a RunnableQueue which is guaranteed to have entered its run() method.
Returns: null if the RunnableQueue has not entered his run() method.
Throws: IllegalStateException if getThread() is null or if the thread returned by getThread() is the current one.
Throws: IllegalStateException if getThread() is null.
Throws: IllegalStateException if getThread() is null or if the thread returned by getThread() is the current one.
Throws: IllegalStateException if getThread() is null.
Throws: IllegalStateException if getThread() is null.
Parameters: rable The runnable that just completed.
Parameters: rable The runnable that is about to start
Parameters: waitTillSuspended if true this method will not return until the queue has suspended (no runnable in progress or about to be in progress). If resumeExecution is called while waiting will simply return (this really indicates a race condition in your code). This may return before an associated RunHandler is notified.
Throws: IllegalStateException if getThread() is null.