public class DirectCallExecutor extends Object
SchedulingContextFactory
to instantiate scheduling contexts.Modifier and Type | Method and Description |
---|---|
Object[] |
call(StateContext stateContext,
Object fn,
Object... args)
Calls
fn(args...) in the current thread in the state context stateContext ,
returning the call result once the call completes. |
static Object[] |
execute(Continuation continuation)
Executes
continuation in the current thread in a scheduling context
that never asks the execution to pause, returning the call result once the call completes. |
static Object[] |
execute(Continuation continuation,
SchedulingContext schedulingContext)
Resumes
continuation in the current thread in the scheduling context
schedulingContext , returning the call result once the call completes. |
static Object[] |
execute(Continuation continuation,
SchedulingContext schedulingContext,
boolean convertResultsToJava)
Resumes
continuation in the current thread in the scheduling context
schedulingContext , returning the call result once the call completes. |
static DirectCallExecutor |
newExecutor()
Returns a new direct call executor with a scheduler that never requests executions
to be paused.
|
static DirectCallExecutor |
newExecutor(SchedulingContextFactory schedulingContextFactory)
Returns a new direct call executor with the specified scheduling context factory used
to instantiate a new scheduling context on each resume.
|
static DirectCallExecutor |
newExecutorWithTickLimit(long ticksLimit)
Returns a new direct call executor that uses that asks each continuation it resumes
to pause after it has registered
ticksLimit ticks. |
Object[] |
resume(Continuation continuation)
Resumes
continuation in the current thread, returning the call result once
the call completes. |
SchedulingContextFactory |
schedulingContextFactory()
Returns the scheduling context factory used by this executor.
|
public static DirectCallExecutor newExecutor()
public static DirectCallExecutor newExecutor(SchedulingContextFactory schedulingContextFactory)
schedulingContextFactory
- the scheduling context factory, must not be null
NullPointerException
- if schedulingContextFactory
is null
public static DirectCallExecutor newExecutorWithTickLimit(long ticksLimit)
ticksLimit
ticks.ticksLimit
- the tick limit for resumes, must be positiveIllegalArgumentException
- if ticksLimit
is not positivepublic SchedulingContextFactory schedulingContextFactory()
public Object[] call(StateContext stateContext, Object fn, Object... args) throws CallException, CallPausedException, InterruptedException
fn(args...)
in the current thread in the state context stateContext
,
returning the call result once the call completes.
The call result will be passed in a freshly-allocated array, and may therefore be manipulated freely by the caller of this method.
stateContext
- state context of the call, must not be null
fn
- the call target, may be null
args
- call arguments, must not be null
CallException
- if the call terminated abnormallyCallPausedException
- if the call initiated a pauseInterruptedException
- when the current thread is interrupted while waiting
for an asynchronous operation to be completedNullPointerException
- if stateContext
or args
is null
public Object[] resume(Continuation continuation) throws CallException, CallPausedException, InterruptedException
continuation
in the current thread, returning the call result once
the call completes.
The call result will be passed in a freshly-allocated array, and may therefore be manipulated freely by the caller of this method.
continuation
- the continuation to resume, must not be null
CallException
- if the call terminated abnormallyCallPausedException
- if the call initiated a pauseInterruptedException
- when the current thread is interrupted while waiting
for an asynchronous operation to be completedInvalidContinuationException
- when continuation
is invalidNullPointerException
- if continuation
is null
public static Object[] execute(Continuation continuation, SchedulingContext schedulingContext, boolean convertResultsToJava) throws CallException, CallPausedException, InterruptedException
continuation
in the current thread in the scheduling context
schedulingContext
, returning the call result once the call completes.
The call result will be passed in a freshly-allocated array, and may therefore
be manipulated freely by the caller of this method. If convertResultsToJava
is true
, the result values will be converted to Java using
Conversions.toJavaValues(Object[])
.
continuation
- the continuation to resume, must not be null
schedulingContext
- the scheduling context, must not be null
convertResultsToJava
- flag controlling the conversion of result values to
their Java representationsconvertResults
is true
CallException
- if the call terminated abnormallyCallPausedException
- if the call initiated a pauseInterruptedException
- when the current thread is interrupted while waiting
for an asynchronous operation to be completedInvalidContinuationException
- when continuation
is invalidNullPointerException
- if continuation
or schedulingContext
is null
public static Object[] execute(Continuation continuation, SchedulingContext schedulingContext) throws CallException, CallPausedException, InterruptedException
continuation
in the current thread in the scheduling context
schedulingContext
, returning the call result once the call completes.
The call result will be passed in a freshly-allocated array, and may therefore be manipulated freely by the caller of this method.
This method converts return values to Java values using
Conversions.toJavaValues(Object[])
. For a greater control over this behaviour,
use execute(Continuation, SchedulingContext, boolean)
instead.
continuation
- the continuation to resume, must not be null
schedulingContext
- the scheduling context, must not be null
CallException
- if the call terminated abnormallyCallPausedException
- if the call initiated a pauseInterruptedException
- when the current thread is interrupted while waiting
for an asynchronous operation to be completedInvalidContinuationException
- when continuation
is invalidNullPointerException
- if continuation
or schedulingContext
is null
public static Object[] execute(Continuation continuation) throws CallException, CallPausedException, InterruptedException
continuation
in the current thread in a scheduling context
that never asks the execution to pause, returning the call result once the call completes.
The call result will be passed in a freshly-allocated array, and may therefore be manipulated freely by the caller of this method.
This method converts return values to Java values using
Conversions.toJavaValues(Object[])
. For a greater control over this behaviour,
use execute(Continuation, SchedulingContext, boolean)
instead.
continuation
- the continuation to resume, must not be null
CallException
- if the call terminated abnormallyCallPausedException
- if the call initiated a pauseInterruptedException
- when the current thread is interrupted while waiting
for an asynchronous operation to be completedInvalidContinuationException
- when continuation
is invalidNullPointerException
- if continuation
or schedulingContext
is null
Copyright © 2016. All rights reserved.