|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.sys.Handle
| Field Summary | |
static int |
Aborted
|
static int |
Changed
|
String |
doing
This is a text version of what the process is currently doing. |
String |
error
If the process stopped due to an error. |
int |
errorCode
This is an application specific error code. |
Object |
errorObject
This can be used for more detailed error handling. |
static int |
Failed
|
static int |
Failure
|
protected int |
nativeResult
This is not to be written to! It is used when interfacing with native threads. |
float |
progress
This gives an indication of the progress of the process. |
float |
progressResolution
If this is set to 0 then a call to changed() is done everytime setProgress() is set, otherwise changed is called only when the progress has increased past the last setProgress() by this value. |
Object |
returnValue
If the process is supposed to produce or return a value, it should be put here. |
static int |
Running
|
boolean |
shouldStop
This gets set to true if the stop() method is called, in addition to it calling the stop() method of the associated task. |
long |
startTime
This is the time that the task started at. |
protected int |
state
This is the state of the handle. |
static int |
Stopped
|
int |
stopReason
This is the reason given to the stop() method. |
static int |
Succeeded
|
static int |
Success
|
Task |
task
This is the Task associated with the handle (if any). |
| Constructor Summary | |
Handle()
|
|
Handle(int status,
Object returnValueOrErrorString)
Create a Handle that has its status preset. |
|
Handle(Task p)
|
|
Handle(Throwable error)
Create a Handle that has its status preset to Failed. |
|
| Method Summary | |
HandleStatus |
callBackOnAnyFlag(CallBack cb,
int flags,
TimeOut t)
|
HandleStatus |
callBackOnFlags(CallBack cb,
int flags,
TimeOut t)
|
void |
callWhenStopped(CallBack cb)
This calls callWhenStopped() with a null timeout. |
void |
callWhenStopped(CallBack cb,
TimeOut timeout)
This causes a CallBack object to be called when the handle is reported as having stopped. |
void |
cancelCallBack(CallBack cb)
|
void |
changed()
This notifies any waiters that something about the handle may have changed. |
int |
check()
This returns the state of the handle. |
boolean |
check(int flags)
Checks to see if all the specified flags have been set. |
boolean |
checkAny(int flags)
Checks to see if any of the specified flags have been set. |
Handle |
clearTag(int tag)
Use this for passing custom data to and from the processes. |
protected HandleStatus |
doCallBackOnFlags(CallBack cb,
int flags,
TimeOut t,
boolean doAll)
|
void |
fail(Throwable t)
Set the Stopped and Failure bits of this Handle and set the errorObject to be the specified Throwable. |
void |
failed(Object error)
Mark the handle as failed and set the errorObject to be error. |
String |
getErrorText(String defaultText)
|
Handle |
getHandle()
Task implementation - This will return itself. |
Handle |
getSubHandle()
|
Handle |
getSubHandle(String doing)
Get a new Handle that will be stopped if this handle is stopped. |
Object |
getTag(int tag,
Object defaultValue)
Use this for passing custom data to and from the processes. |
Task |
getTask()
|
boolean |
hasStopped()
Returns whether the Stopped bit has been set. |
void |
resetProgress(float progressResolution)
|
void |
resetTime(String doing)
This method does the following: It sets the doing field to the specified parameter. |
void |
set(int newstate)
Everytime it is called it will ensure that any waiting Coroutines get notified so they can check to see if the state they are waiting for has been achieved. |
void |
setFlags(int switchOn,
int switchOff)
This sets and clears specific flags (bits) in the handle state. |
void |
setProgress(float progress)
|
Handle |
setTag(int tag,
Object value)
Use this for passing custom data to and from the processes. |
void |
start()
This tells the handle to ask its associated task to start. |
Handle |
startDoing(String doing)
A convenience method that calls resetTime(doing) and then returns itself. |
Handle |
startTask()
Task implementation - this will set the state of the handle to Running. |
void |
stop(int reason)
This tells the handle to ask its associated task to stop. |
void |
stopAlsoIfStopped(Handle otherHandle)
If the stop() method of this handle is called it will call stop() on the other handle. |
Handle |
stopTask(int reason)
Task implementation - this will do nothing! |
void |
ticked(int id,
int elapsed)
|
void |
waitOn(int flags)
This causes the current mThread to wait indefinitely until the status of the Handle has ALL the flag bits set as specified by the "flags" parameter, or until the Handle has the Stopped bit set (in which case an Exception is thrown). |
boolean |
waitOn(int flags,
int t)
This causes the current mThread to wait until the status of the Handle has ALL the flag bits set as specified by the "flags" parameter, or until the Timout specified expires, or until the Handle has the Stopped bit set (in which case an Exception is thrown). |
boolean |
waitOn(int flags,
TimeOut t)
This causes the current mThread to wait until the status of the Handle has ALL the flag bits set as specified by the "flags" parameter, or until the Timout specified expires, or until the Handle has the Stopped bit set (in which case an Exception is thrown). |
boolean |
waitOn(int flags,
TimeOut checkTimeOut,
Handle masterHandle,
TimeOut masterTimeOut)
This is used by one task to check on the progress of another. |
void |
waitOnAny(int flags)
This causes the current mThread to wait indefinitely until the status of the Handle has at least one of the flag bits set as specified by the "flags" parameter, or until the Handle has the Stopped bit set (in which case an Exception is thrown). |
boolean |
waitOnAny(int flags,
int t)
This causes the current mThread to wait until the status of the Handle has at least one of the flag bits set as specified by the "flags" parameter set, or until the Timout specified expires, or until the Handle has the Stopped bit set (in which case an Exception is thrown). |
boolean |
waitOnAny(int flags,
TimeOut t)
This causes the current mThread to wait until the status of the Handle has at least one of the flag bits set as specified by the "flags" parameter set, or until the Timout specified expires, or until the Handle has the Stopped bit set (in which case an Exception is thrown). |
boolean |
waitOnAny(int flags,
TimeOut checkTimeOut,
Handle masterHandle,
TimeOut masterTimeOut)
This is used by one task to check on the progress of another. |
int |
waitOnAnyFlag(int flags,
TimeOut t)
Deprecated. - use waitOnAny(int flags,TimeOut t) instead. |
boolean |
waitOnFlags(int flags,
TimeOut t)
Deprecated. - use waitOn(int flags,TimeOut t) instead. |
boolean |
waitOnFlags(int flags,
TimeOut checkTimeOut,
Handle masterHandle,
TimeOut masterTimeOut)
Deprecated. - use waitOn(int flags,TimeOut checkTimeOut,Handle masterHandle,TimeOut masterTimeOut) instead. |
void |
waitUntilStopped()
Wait until the Handle has stopped. |
boolean |
waitUntilStopped(TimeOut howLong)
Wait until the Handle has stopped. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, toString |
| Field Detail |
protected int nativeResult
public Object returnValue
public float progress
public static final int Changed
public static final int Stopped
public static final int Success
public static final int Failure
public static final int Running
public static final int Aborted
public static final int Succeeded
public static final int Failed
public Task task
protected int state
public String doing
public int errorCode
public String error
public Object errorObject
public long startTime
public boolean shouldStop
public int stopReason
public float progressResolution
| Constructor Detail |
public Handle(int status,
Object returnValueOrErrorString)
public Handle(Throwable error)
error - An errorpublic Handle()
public Handle(Task p)
| Method Detail |
public final Task getTask()
public Handle getSubHandle(String doing)
public Handle getSubHandle()
public void fail(Throwable t)
public final void changed()
public final void set(int newstate)
public final void setFlags(int switchOn,
int switchOff)
switchOn - Flag bits to switch on.switchOff - Flag bits to swtich off.
public void ticked(int id,
int elapsed)
ticked in interface TimerProcpublic final int check()
public final boolean waitOn(int flags,
TimeOut t)
throws HandleStoppedException,
InterruptedException
flags - The flag bits to wait for. Must NOT be zero; an IllegalArgumentException is thrown if it is.t - The TimeOut to wait for.
HandleStoppedException - If the handle has the Stopped flag set before all the flags were set.
InterruptedException - If the Thread was interrupted.
public final boolean waitOn(int flags,
int t)
throws HandleStoppedException,
InterruptedException
flags - The flag bits to wait for. Must NOT be zero; an IllegalArgumentException is thrown if it is.t - The time in milliseconds to wait.
HandleStoppedException - If the handle has the Stopped flag set before all the flags were set.
InterruptedException - If the Thread was interrupted.
public final void waitOn(int flags)
throws HandleStoppedException,
InterruptedException
flags - The flag bits to wait for. Must NOT be zero; an IllegalArgumentException is thrown if it is.
HandleStoppedException - If the handle has the Stopped flag set before all the flags were set.
InterruptedException - If the Thread was interrupted.
public final boolean waitOnAny(int flags,
TimeOut t)
throws HandleStoppedException,
InterruptedException
flags - The flag bits to wait for. Must NOT be zero; an IllegalArgumentException is thrown if it is.t - The TimeOut to wait for.
HandleStoppedException - If the handle has the Stopped flag set before all the flags were set.
InterruptedException - If the Thread was interrupted.
public final boolean waitOnAny(int flags,
int t)
throws HandleStoppedException,
InterruptedException
flags - The flag bits to wait for. Must NOT be zero; an IllegalArgumentException is thrown if it is.t - The time in milliseconds to wait.
HandleStoppedException - If the handle has the Stopped flag set before all the flags were set.
InterruptedException - If the Thread was interrupted.
public final void waitOnAny(int flags)
throws HandleStoppedException,
InterruptedException
flags - The flag bits to wait for. Must NOT be zero; an IllegalArgumentException is thrown if it is.
HandleStoppedException - If the handle has the Stopped flag set before all the flags were set.
InterruptedException - If the Thread was interrupted.
public final boolean waitUntilStopped(TimeOut howLong)
throws InterruptedException
howLong - How long to wait for.
InterruptedException - if the Thread was interrupted.
public final void waitUntilStopped()
throws InterruptedException
InterruptedException - if the Thread was interrupted.
public final boolean check(int flags)
throws HandleStoppedException
flags - The flag bits to check for.
HandleStoppedException - If the handle has the Stopped flag set AND the handle does
not have the specified flag bits set.
public final boolean checkAny(int flags)
throws HandleStoppedException
flags - The flag bits to check for.
HandleStoppedException - If the handle has the Stopped flag set AND the handle does
not have any of the specified flag bits set.
public final boolean waitOnFlags(int flags,
TimeOut t)
public final int waitOnAnyFlag(int flags,
TimeOut t)
protected final HandleStatus doCallBackOnFlags(CallBack cb,
int flags,
TimeOut t,
boolean doAll)
public final HandleStatus callBackOnFlags(CallBack cb,
int flags,
TimeOut t)
public final HandleStatus callBackOnAnyFlag(CallBack cb,
int flags,
TimeOut t)
public final void cancelCallBack(CallBack cb)
public void stop(int reason)
public void start()
public Handle getHandle()
getHandle in interface Taskpublic Handle startTask()
startTask in interface Taskpublic Handle stopTask(int reason)
stopTask in interface Task
public void callWhenStopped(CallBack cb,
TimeOut timeout)
cb - the CallBack object to be called when the handle has stopped. The callBack() method will be called
with this handle as the parameter. However if the timeout expired before this handle stopped,
then the parameter to the callBack() method will be null. Note that the callBack() method is called within
a Coroutine.timeout - An optional time to wait. If this is null it will wait forever.public void callWhenStopped(CallBack cb)
public boolean hasStopped()
public boolean waitOnFlags(int flags,
TimeOut checkTimeOut,
Handle masterHandle,
TimeOut masterTimeOut)
public boolean waitOn(int flags,
TimeOut checkTimeOut,
Handle masterHandle,
TimeOut masterTimeOut)
throws HandleStoppedException,
InterruptedException
public boolean waitOn(int flags,TimeOut checkTimeOut,Handle masterHandle,TimeOut masterTimeOut) throws HandleStoppedException
{
while(true){
if (masterTimeOut.hasExpired() || masterHandle.shouldStop) return false;
if (waitOn(flags,checkTimeOut.reset())) return true;
}
}
flags - The bits to check for.checkTimeOut - How long to check this Handle for each iteration.masterHandle - The master handle controlling the operation.masterTimeOut - The length of time the masterHandle is waiting for.
HandleStoppedException - if this handle has its Stopped bits set.
InterruptedException - If the Thread was interrupted.
public boolean waitOnAny(int flags,
TimeOut checkTimeOut,
Handle masterHandle,
TimeOut masterTimeOut)
throws HandleStoppedException,
InterruptedException
public boolean waitOnAny(int flags,TimeOut checkTimeOut,Handle masterHandle,TimeOut masterTimeOut) throws HandleStoppedException
{
while(true){
if (masterTimeOut.hasExpired() || masterHandle.shouldStop) return false;
if (waitOnAny(flags,checkTimeOut.reset())) return true;
}
}
flags - The bits to check for.checkTimeOut - How long to check this Handle for each iteration.masterHandle - The master handle controlling the operation.masterTimeOut - The length of time the masterHandle is waiting for.
HandleStoppedException - if this handle has its Stopped bits set.
InterruptedException - If the Thread was interrupted.public void resetProgress(float progressResolution)
public void setProgress(float progress)
public void failed(Object error)
public String getErrorText(String defaultText)
public void resetTime(String doing)
doing - the new value for the doing field.public Handle startDoing(String doing)
doing - The current task.
public Handle setTag(int tag,
Object value)
tag - a custom integer tag.value - a value to pass.
public Object getTag(int tag,
Object defaultValue)
tag - a custom integer tag.defaultValue - the default value.
public void stopAlsoIfStopped(Handle otherHandle)
public Handle clearTag(int tag)
tag - a custom integer tag to clear.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||