com.samskivert.util
Class SerialExecutor

java.lang.Object
  extended by com.samskivert.util.SerialExecutor

public class SerialExecutor
extends Object

Executes tasks serially, but each one on a separate thread. If a task times out, the executor will attempt to interrupt the thread and abort the task, but will abandon the thread in any case after the abort attempt so that subsequent tasks can be processed. The threads created are daemon threads so that they will not block the eventual termination of the virtual machine.


Nested Class Summary
static interface SerialExecutor.ExecutorTask
          A task to run in serial on the executor.
protected  class SerialExecutor.ExecutorThread
          The basic processing unit of the Executor.
 
Field Summary
protected  boolean _executingNow
          True if there is a thread currently executing a task.
protected  ArrayList<SerialExecutor.ExecutorTask> _queue
          The queue of tasks to execute.
protected  RunQueue _receiver
          The receiver to which we post a unit to process results.
 
Constructor Summary
SerialExecutor(RunQueue receiver)
          Construct the SerialExecutor.
 
Method Summary
 void addTask(SerialExecutor.ExecutorTask task)
          Add a task to the executor, it is expected that this method is called on the ResultReceiver thread.
protected  void checkNext()
          Execute the next task, if applicable.
 int getQueueSize()
          Returns the number of ExecutorTasks that are currently waiting on the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_receiver

protected RunQueue _receiver
The receiver to which we post a unit to process results.


_executingNow

protected boolean _executingNow
True if there is a thread currently executing a task.


_queue

protected ArrayList<SerialExecutor.ExecutorTask> _queue
The queue of tasks to execute.

Constructor Detail

SerialExecutor

public SerialExecutor(RunQueue receiver)
Construct the SerialExecutor.

Method Detail

addTask

public void addTask(SerialExecutor.ExecutorTask task)
Add a task to the executor, it is expected that this method is called on the ResultReceiver thread.


getQueueSize

public int getQueueSize()
Returns the number of ExecutorTasks that are currently waiting on the queue.


checkNext

protected void checkNext()
Execute the next task, if applicable.



Copyright © 2000-2008 Michael Bayne. All Rights Reserved.