ini.trakem2.utils
Class Worker

java.lang.Object
  extended by ini.trakem2.utils.Worker
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
Worker.Task

public abstract class Worker
extends java.lang.Object
implements java.lang.Runnable


Nested Class Summary
static class Worker.Task
          A class that calls run() wrapped properly for task monitoring; Create it like this: Bureaucrat b = Bureaucrat.createAndStart(new Worker.Task("Title") { public void exec() { doSomething(); doSomethingElse(); }}, project);
 
Field Summary
protected  boolean quit
           
protected  java.lang.Object result
          Extending classes may store a resulting piece of data.
 
Constructor Summary
Worker(java.lang.String task_name)
           
Worker(java.lang.String task_name, boolean headless_mode)
           
Worker(java.lang.String task_name, boolean headless_mode, boolean interrupt_on_quit)
           
 
Method Summary
 void cleanup()
          When quitted or interrupted, executes this method once.
protected  void finishedWorking()
           
 java.lang.Object getProperty(java.lang.Object key)
           
 java.lang.Object getResult()
          Returns data generated by the worker, or null if none was set.
 java.lang.String getTaskName()
           
 java.lang.String getThreadName()
           
 boolean hasQuitted()
           
 boolean hasStarted()
           
 boolean isWorking()
           
 void join()
           
 boolean onBackground()
          Whether the work is done on the background, without need to bring ImageJ toolbar to front for instance.
 void quit()
          If interrupt_on_quit, then it will call thread.getThreadGroup().interrupt() to set a quit flag to each child thread.
protected  void setAsBackground(boolean b)
           
 void setPriority(int priority)
           
 void setProperty(java.lang.Object key, java.lang.Object value)
           
 void setTaskName(java.lang.String name)
           
protected  void startedWorking()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Runnable
run
 

Field Detail

quit

protected volatile boolean quit

result

protected java.lang.Object result
Extending classes may store a resulting piece of data.

Constructor Detail

Worker

public Worker(java.lang.String task_name)

Worker

public Worker(java.lang.String task_name,
              boolean headless_mode)

Worker

public Worker(java.lang.String task_name,
              boolean headless_mode,
              boolean interrupt_on_quit)
Method Detail

setTaskName

public void setTaskName(java.lang.String name)

startedWorking

protected void startedWorking()

hasStarted

public boolean hasStarted()

finishedWorking

protected void finishedWorking()

isWorking

public boolean isWorking()

getTaskName

public java.lang.String getTaskName()

getThreadName

public java.lang.String getThreadName()

setPriority

public void setPriority(int priority)

quit

public void quit()
If interrupt_on_quit, then it will call thread.getThreadGroup().interrupt() to set a quit flag to each child thread.


join

public void join()
          throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

hasQuitted

public boolean hasQuitted()

setAsBackground

protected void setAsBackground(boolean b)

onBackground

public boolean onBackground()
Whether the work is done on the background, without need to bring ImageJ toolbar to front for instance.


cleanup

public void cleanup()
When quitted or interrupted, executes this method once.


getResult

public java.lang.Object getResult()
Returns data generated by the worker, or null if none was set.


setProperty

public void setProperty(java.lang.Object key,
                        java.lang.Object value)

getProperty

public java.lang.Object getProperty(java.lang.Object key)