org.objectweb.proactive.calcium
Class Task<T>

java.lang.Object
  extended by org.objectweb.proactive.calcium.Task<T>
Type Parameters:
T -
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Task>

public class Task<T>
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable<Task>

This class is the main wrapper class for the objects passed to the Skernel. A regular user should never know that this class exists. Among others, this class: provides a wrapper for the user parameters, holds the intstruction stack for this task, handles the creation and conquer of child tasks (subtasks).

Author:
The ProActive Team (mleyton)
See Also:
Serialized Form

Field Summary
static int DEFAULT_PRIORITY
           
 
Constructor Summary
Task()
           
Task(T object)
           
 
Method Summary
 void addReadyChild(Task<T> child)
          Adds a subtask ready for execution.
 int compareTo(Task task)
           
 boolean equals(java.lang.Object o)
           
 boolean equals(Task<T> task)
           
 java.lang.Exception getException()
           
 int getFamilyId()
           
 Task<T> getFinishedChild()
           
 int getId()
           
 T getObject()
           
 int getParentId()
           
 int getPriority()
           
 Task<T> getReadyChild()
          Gets a sub task ready for execution.
 java.util.Vector<Instruction<T>> getStack()
          Gives a not so shallow copy of the stack.
 StatsImpl getStats()
           
 int getStreamId()
           
 boolean hasException()
           
 boolean hasFinishedChild()
           
 int hashCode()
           
 boolean hasInstruction()
           
 boolean hasReadyChildTask()
           
 boolean isDummy()
           
 boolean isFinished()
           
 boolean isReady()
           
 boolean isRootTask()
           
 boolean isTainted()
           
 void markFinishTime()
           
 Instruction<T> peekInstruction()
           
 Instruction<T> popInstruction()
           
 void pushInstruction(Instruction<T> inst)
           
 Task<T> reBirth(T object)
          Makes a new task that represents a rebirth of the current one.
 void setDummy()
           
 void setException(java.lang.Exception exception)
           
 boolean setFinishedChild(Task<?> task)
           
 void setObject(T object)
           
 void setPriority(int newPriority)
           
 void setStack(java.util.Vector<Instruction<T>> v)
          Sets a not so shallow reference to the parameter stack.
 void setStreamId(int streamId)
           
 void setTainted(boolean isTainted)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_PRIORITY

public static int DEFAULT_PRIORITY
Constructor Detail

Task

public Task()

Task

public Task(T object)
Method Detail

reBirth

public Task<T> reBirth(T object)
Makes a new task that represents a rebirth of the current one. All parameters like: id, priority, parentId, computationTime, and current instruction stack are preserved. The child (subtasks) references are not preserved, and the contained object is the one passed as parameter.

Parameters:
object - The new object to be hold in this task.
Returns:
A new birth of the current task containting object

compareTo

public int compareTo(Task task)
Specified by:
compareTo in interface java.lang.Comparable<Task>

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(Task<T> task)

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

getStack

public java.util.Vector<Instruction<T>> getStack()
Gives a not so shallow copy of the stack. Modifications to the return value stack will not be reflected on the Task's stack. But, modifications on the stack objects will be reflected.

Returns:

setStack

public void setStack(java.util.Vector<Instruction<T>> v)
Sets a not so shallow reference to the parameter stack. Further modifications on the parameter will not modify the internal stack. But, modifications on the stack values will be modified.

Parameters:
v -

getParentId

public int getParentId()
Returns:
Returns the parent task's id.

hasInstruction

public boolean hasInstruction()

hasReadyChildTask

public boolean hasReadyChildTask()

popInstruction

public Instruction<T> popInstruction()

peekInstruction

public Instruction<T> peekInstruction()

pushInstruction

public void pushInstruction(Instruction<T> inst)

getObject

public T getObject()

setObject

public void setObject(T object)

getId

public int getId()
Returns:
Returns the id of the task.

getPriority

public int getPriority()
Returns:
Returns the priority.

setPriority

public void setPriority(int newPriority)

getReadyChild

public Task<T> getReadyChild()
Gets a sub task ready for execution. Internally, the subtask will be remembered by putting it in the waite queue.

Returns:
A sub task ready for execution.

addReadyChild

public void addReadyChild(Task<T> child)
Adds a subtask ready for execution. This subtask will be configured with the parent id (this task's id), and also with a priority higher than it's parent.

Parameters:
child - The sub task.

setFinishedChild

public boolean setFinishedChild(Task<?> task)

isFinished

public boolean isFinished()

isReady

public boolean isReady()

hasFinishedChild

public boolean hasFinishedChild()

getFinishedChild

public Task<T> getFinishedChild()

isRootTask

public boolean isRootTask()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isDummy

public boolean isDummy()

setDummy

public void setDummy()

getException

public java.lang.Exception getException()
Returns:
Returns the exception.

setException

public void setException(java.lang.Exception exception)
Parameters:
exception - The exception to set.

hasException

public boolean hasException()

getFamilyId

public int getFamilyId()
Returns:
Returns the familyId.

isTainted

public boolean isTainted()
Returns:
true if this task is tainted

setTainted

public void setTainted(boolean isTainted)
Parameters:
isTainted - true sets this task to tainted

markFinishTime

public void markFinishTime()

getStats

public StatsImpl getStats()

getStreamId

public int getStreamId()
Returns:
Returns the id of the stream that created this task.

setStreamId

public void setStreamId(int streamId)
Parameters:
streamId - Sets the id of the stream that created this task.


Copyright 2001-2007 INRIA All Rights Reserved.