live.threads
Class Runner

java.lang.Object
  extended byjava.lang.Thread
      extended bylive.threads.ThreadedUserAction
          extended bylive.threads.Runner
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
ParallelRunner, SequentialRunner

public abstract class Runner
extends ThreadedUserAction

This class is a container that holds ThreadedUserActions that should be run later. It is itself a ThreadedUserAction, so has run(), start(), etc. methods. In this case, when they are called, the runner should kick off all the tasks that it has stored. There are (TODO) two concrete subclasses of this, SequentialRunner and ParallelRunner, based upon whether the tasks can be run in parallel or not. (Note that the distinction is NOT upon whether they actually do run in parallel, just whether they can. See the docs for each of these for more detail, especially ParallelRunner.) To use this, make an object of one of the concrete runners, call schedule(ThreadedUserAction) for each task you want to run, then call Thread.start() or any of the other functions that will start the thread. To retrieve the results, call rawResult(). This returns a linked list of the ThreadedUserActions that were passed to schedule(...) before. You can iterate through this list and call ThreadedUserAction.rawResult() on each of them. Also, ThreadedUserAction.result() should return an error message if an exception is thrown by one of the threads (subject to its implementation by a subclass).

Author:
Evan Driscoll

Nested Class Summary
 
Nested classes inherited from class live.threads.ThreadedUserAction
 
Field Summary
private  String description
          This stores occurances of exceptions and the task that caused them so they can be reported
protected  ThreadInitInfo initInfo
           
private  ThreadInitInfo modifiedInfo
          This holds a modified version of the ThreadInitInfo object that was passed in.
protected  LinkedList taskList
           
 
Fields inherited from class live.threads.ThreadedUserAction
CANCELED, COMPLETE, done, ERROR, IN_PROGRESS, INDETERMINATE, PENDING, tasks
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Runner()
           
 
Method Summary
 String description()
          This returns the description set in init
 void init(ThreadInitInfo info, String description)
          Does the trickery necessary in order to create a new ThreadInitInfo object local to the thread.
 void init(ThreadInitInfo info, String description, boolean removeLists)
          Does the trickery necessary in order to create a new ThreadInitInfo object local to the thread.
 Object rawResult()
          Returns the tasks that are to be/are being/have been done
 void schedule(ThreadedUserAction action)
          This adds action to the list of subactions that will be run
 void setCanceled()
          Sets the thread as canceled
 
Methods inherited from class live.threads.ThreadedUserAction
getCache, getException, getID, getStatus, getTimeFinished, getTimeStarted, init, init, isFinished, result, run, runImpl, setComplete, setError, setError, setIndeterminate, setIndeterminate, setInProgress, startJoinForever, startJoinTimeout, startNoJoin, toString
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

description

private String description
This stores occurances of exceptions and the task that caused them so they can be reported


modifiedInfo

private ThreadInitInfo modifiedInfo
This holds a modified version of the ThreadInitInfo object that was passed in. In order that every subaction not show up in the status page, the session's threadinfo object can't be used. So init(ThreadInitInfo, String) takes the ThreadInitInfo passed in, and makes a new one local to the runner with the same ConnectionInfo and a different ActiveThreadsInfo. (TODO: make teh local Active object)


taskList

protected LinkedList taskList

initInfo

protected ThreadInitInfo initInfo
Constructor Detail

Runner

public Runner()
Method Detail

init

public final void init(ThreadInitInfo info,
                       String description)
Does the trickery necessary in order to create a new ThreadInitInfo object local to the thread. Also, stores the description. This is not really intended to be called publically, just by derived classes.

Parameters:
info -
description -

init

public final void init(ThreadInitInfo info,
                       String description,
                       boolean removeLists)
Does the trickery necessary in order to create a new ThreadInitInfo object local to the thread. Also, stores the description. This is not really intended to be called publicly, just by derived classes.

Parameters:
info -
description -
removeLists -

schedule

public void schedule(ThreadedUserAction action)
This adds action to the list of subactions that will be run

Parameters:
action - The action to schedule

description

public String description()
This returns the description set in init

Specified by:
description in class ThreadedUserAction
Returns:
A human-readable summary of the action being performed
See Also:
ThreadedUserAction.description()

rawResult

public Object rawResult()
Returns the tasks that are to be/are being/have been done

Specified by:
rawResult in class ThreadedUserAction
Returns:
The result of the action. (See subclasses for individual definitions.)

setCanceled

public void setCanceled()
Sets the thread as canceled

Overrides:
setCanceled in class ThreadedUserAction


Copyright © 2005