dk.brics.xact.analysis.concurrent
Class ExecutorTaskRunner

java.lang.Object
  extended by dk.brics.xact.analysis.concurrent.ExecutorTaskRunner
All Implemented Interfaces:
XactTaskRunner

public class ExecutorTaskRunner
extends Object
implements XactTaskRunner

Adapter for ExecutorService to XactTaskRunner.


Constructor Summary
ExecutorTaskRunner(ExecutorService service)
           
 
Method Summary
 void addTask(Runnable runnable)
          Adds a tasks to the task scheduler.
 boolean maybeMultiThreaded()
          Returns true if the scheduler might be multithreaded, or false if it is definitely not multithreaded.
 void runTasks()
          Runs all scheduled tasks and returns when all have completed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExecutorTaskRunner

public ExecutorTaskRunner(ExecutorService service)
Method Detail

addTask

public void addTask(Runnable runnable)
Description copied from interface: XactTaskRunner
Adds a tasks to the task scheduler. The task will not be run until the next invocation of XactTaskRunner.runTasks().

Specified by:
addTask in interface XactTaskRunner
Parameters:
runnable - the task to be executed

maybeMultiThreaded

public boolean maybeMultiThreaded()
Description copied from interface: XactTaskRunner
Returns true if the scheduler might be multithreaded, or false if it is definitely not multithreaded.

If not multithreaded, the analysis can occasionally skip certain tasks that only exist to avoid interference.

Specified by:
maybeMultiThreaded in interface XactTaskRunner
Returns:
false if definitely single-threaded, otherwise true

runTasks

public void runTasks()
Description copied from interface: XactTaskRunner
Runs all scheduled tasks and returns when all have completed. The queue of tasks is cleared after this.

Throws a runtime exception if any of the tasks terminated with an unhandled exception.

Specified by:
runTasks in interface XactTaskRunner


Copyright © 2005-2011 Aarhus University.