Interface ComputeJobContinuation
-
- All Known Subinterfaces:
ComputeJobContext
- All Known Implementing Classes:
ComputeJobContinuationAdapter
public interface ComputeJobContinuation
Defines continuation support for grid job context.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
callcc()
Resumes job if it was held byholdcc()
method.boolean
heldcc()
Checks if job execution has been temporarily held (suspended).<T> T
holdcc()
Holds (suspends) a given job indefinitely untilcallcc()
is called.<T> T
holdcc(long timeout)
Holds (suspends) a given job for specified timeout or untilcallcc()
is called.
-
-
-
Method Detail
-
heldcc
boolean heldcc()
Checks if job execution has been temporarily held (suspended).If job has completed its execution, then
false
is always returned.- Returns:
True
if job has been held.
-
holdcc
@Nullable <T> T holdcc()
Holds (suspends) a given job indefinitely untilcallcc()
is called. Job will remain in active queue, but itsheldcc()
method will returntrue
. Implementations ofCollisionSpi
should check if jobs are held or not as needed.All jobs should stop their execution and return right after calling
'holdcc(..)'
method. For convenience, this method always returnsnull
, so you can hold and return in one line by calling'return holdcc()'
method.If job is not running or has completed its execution, then no-op.
The
'cc'
suffix stands for'current-continuation'
which is a pretty standard notation for this concept that originated from Scheme programming language. Basically, the job is held to be continued later, hence the name of the method.- Type Parameters:
T
- Type of the job execution result.- Returns:
- Always returns
null
for convenience to be used in code with return statement. - Throws:
IllegalStateException
- If job has been already held before.
-
holdcc
@Nullable <T> T holdcc(long timeout)
Holds (suspends) a given job for specified timeout or untilcallcc()
is called. Holds (suspends) a given job for specified timeout or untilcallcc()
is called. Job will remain in active queue, but itsheldcc()
method will returntrue
. Implementations ofCollisionSpi
should check if jobs are held or not as needed.All jobs should stop their execution and return right after calling
'holdcc(..)'
method. For convenience, this method always returnsnull
, so you can hold and return in one line by calling'return holdcc()'
.If job is not running or has completed its execution, then no-op.
The
'cc'
suffix stands for'current-continuation'
which is a fairly standard notation for this concept. Basically, the job is held to be continued later, hence the name of the method.- Type Parameters:
T
- Type of the job execution result.- Parameters:
timeout
- Timeout in milliseconds after which job will be automatically resumed.- Returns:
- Always returns
null
for convenience to be used in code with return statement. - Throws:
IllegalStateException
- If job has been already held before
-
callcc
void callcc()
Resumes job if it was held byholdcc()
method. Resuming job means thatComputeJob.execute()
method will be called again. It is user's responsibility to check, as needed, whether job is executing from scratch and has been resumed.Note that the job is resumed with exactly the same state as of when it was 'held' via the
holdcc()
method.If job is not running, has not been suspended, or has completed its execution, then no-op.
The method is named after
'call-with-current-continuation'
design pattern, commonly abbreviated as'call/cc'
, which originated in Scheme programming language.
-
-