Package io.engineblock.activityapi.core
Class BaseAsyncAction<D,A extends Activity>
- java.lang.Object
-
- io.engineblock.activityapi.core.BaseAsyncAction<D,A>
-
- Type Parameters:
D- An type of state holder for an operation, holding everything unique to that cycle and operationA- An type of of an Activity, a state holder for a runtime instance of an Activity
- All Implemented Interfaces:
Action,ActivityDefObserver,AsyncAction<D>,Stoppable
public abstract class BaseAsyncAction<D,A extends Activity> extends java.lang.Object implements AsyncAction<D>, Stoppable, ActivityDefObserver
-
-
Constructor Summary
Constructors Constructor Description BaseAsyncAction(A activity, int slot)
-
Method Summary
Modifier and Type Method Description booleanenqueue(TrackedOp<D> opc)THIS DOCUMENTATION IS LIKELY OUT OF DATE The responsibility for tracking async pending against concurrency limits, including signaling for thread state, has been moved into the async event loop of the core motor.voidonActivityDefUpdate(ActivityDef activityDef)voidrequestStop()Ask this component to stop cycling.abstract voidstartOpCycle(TrackedOp<D> opc)Implementations that extend this base class can call this method in order to put an operation in flight.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.engineblock.activityapi.core.AsyncAction
getOpInitFunction
-
-
-
-
Constructor Detail
-
BaseAsyncAction
public BaseAsyncAction(A activity, int slot)
-
-
Method Detail
-
onActivityDefUpdate
public void onActivityDefUpdate(ActivityDef activityDef)
- Specified by:
onActivityDefUpdatein interfaceActivityDefObserver
-
enqueue
public boolean enqueue(TrackedOp<D> opc)
Description copied from interface:AsyncActionTHIS DOCUMENTATION IS LIKELY OUT OF DATE The responsibility for tracking async pending against concurrency limits, including signaling for thread state, has been moved into the async event loop of the core motor. If this experiment holds, then the docs here must be rewritten to be accurate for that approach. Enqueue a cycle to be executed by the action. This method should block unless or until the action accepts the cycle to be processed. This method is not allowed to reject a cycle. If it is unable to accept the cycle for any reason, it must throw an exception. Since the action implementation is presumed to be running some externally asynchronous process to support the action, it is up to the action itself to control when to block enqueueing. If the action is not actually asynchronous, then it may need to do downstream processing in order to open room in its concurrency limits for the new cycle. Each action implementation is responsible for tracking and controlling its own limits of concurrency. TheBaseAsyncActionbase class is a convenient starting point for such implementations. If the action is known to have additional open slots for an operations to be started (according to the configured concurrency limits), then it can signal such by returning true from this method.- Specified by:
enqueuein interfaceAsyncAction<D>- Parameters:
opc- The op context that holds state for this operation- Returns:
- true, if the action is ready immediately for another operation
-
startOpCycle
public abstract void startOpCycle(TrackedOp<D> opc)
Implementations that extend this base class can call this method in order to put an operation in flight.- Parameters:
opc- A tracked operation with state of parameterized type D
-
requestStop
public void requestStop()
Description copied from interface:StoppableAsk this component to stop cycling. This is an asynchronous request. Once the current active cycle completes, the request will cause the component to stop cooperatively.- Specified by:
requestStopin interfaceStoppable
-
-