edu.ucsb.cs.jicos.services
Class Task

java.lang.Object
  extended by edu.ucsb.cs.jicos.services.Task
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AddInteger, BranchAndBound, Compose, Fibonacci, TaskExternal

public abstract class Task
extends java.lang.Object
implements java.io.Serializable

See Also:
Serialized Form

Field Summary
static int ALL_INPUTS
           
 
Constructor Summary
Task()
          A no argument constructor is needed by RMI when unmarshalling arguments and/or return values.
 
Method Summary
 void compute(Task task)
          This is used to "dispatch" a subtask (its argument).
abstract  java.lang.Object execute(Environment environment)
          This method implements the computation encapsulated by this task.
 java.lang.Object execute(Environment environment, int inputIndex)
          This method is used to process inputs as they arrive, instead of waiting until they all have arrived.
 boolean executeIncrementally(Environment environment)
          If true, invoke execute( Environment environment, int inputIndex) as each input is received.
 boolean executeOnServer(Environment environment)
          Invoke this task's execute method on the originating TaskServer if and only if this method evaluates to true.
 java.lang.Object getInput(int i)
          Returns input[i].
 edu.ucsb.cs.jicos.services.TaskId getTaskId()
          get the TaskId of this Task.
 boolean isAtomic(Environment environment)
          The host that is invoking this task's execute method will pre-fetch a task if and only if this method evaluates to true.
 int numInputs()
          Returns the number of inputs to this computational task.
 int numUnsetInputs()
           
 java.lang.String toString()
          returns a String representation of the Task.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALL_INPUTS

public static final int ALL_INPUTS
See Also:
Constant Field Values
Constructor Detail

Task

public Task()
A no argument constructor is needed by RMI when unmarshalling arguments and/or return values.

Method Detail

compute

public final void compute(Task task)
This is used to "dispatch" a subtask (its argument). The subtask is ready for immediate execution. This method is not used to dispatch compose tasks. They are conveyed as the execute method's returned value.

Parameters:
task - A subtask of this task. It has all its inputs, thus is ready for execution. Its successor is a Compose task.

execute

public abstract java.lang.Object execute(Environment environment)
This method implements the computation encapsulated by this task. The method is the Task class's reason for being.

Parameters:
environment - The task's environment: The computation's immutable input & its Shared Object, if any.
Returns:
The returned Object is either the execute method's computed value xor a (compose) Task. In the latter case, the compose task takes the output from this task's subtasks, and composes it to create this task's output. This, at least, is the intent of this method's returned value.

execute

public java.lang.Object execute(Environment environment,
                                int inputIndex)
This method is used to process inputs as they arrive, instead of waiting until they all have arrived.

Parameters:
environment - The task's environment: The computation's immutable input & its Shared Object, if any.
Returns:
The returned Object is either the execute method's computed value xor a (compose) Task - which takes the output from this task's subtasks, and composes it to create this task's output. This, at least, is the intent of this method's returned value xor a ContinueSignal "Task" - which indicates that the task is not complete, and is waiting for more inputs.

executeOnServer

public boolean executeOnServer(Environment environment)
Invoke this task's execute method on the originating TaskServer if and only if this method evaluates to true.

Parameters:
environment - The Environment for this session.
Returns:
true if and only if the task's execute method is to be invoked by the originating TaskServer.

getInput

public final java.lang.Object getInput(int i)
Returns input[i].

Parameters:
i - The index of the desired input array element.
Returns:
input[i].

numUnsetInputs

public final int numUnsetInputs()

getTaskId

public final edu.ucsb.cs.jicos.services.TaskId getTaskId()
get the TaskId of this Task. Not necessary for application deployment, but may be useful when testing.

Returns:
the TaskId of this Task.

isAtomic

public boolean isAtomic(Environment environment)
The host that is invoking this task's execute method will pre-fetch a task if and only if this method evaluates to true.

Parameters:
environment - The session environment.
Returns:
true if the task should signal the its host to pre-fetch another task before invoking this task's execute method.

executeIncrementally

public boolean executeIncrementally(Environment environment)
If true, invoke execute( Environment environment, int inputIndex) as each input is received.


numInputs

public final int numInputs()
Returns the number of inputs to this computational task.

Returns:
the number of inputs to this computational task.

toString

public java.lang.String toString()
returns a String representation of the Task.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of the Task:


Jicos: http://cs.ucsb.edu/projects/jicos