Package io.engineblock.activityapi.core
Interface Activity
-
- All Superinterfaces:
ActivityDefObserver,java.lang.Comparable<Activity>
- All Known Implementing Classes:
SimpleActivity
public interface Activity extends java.lang.Comparable<Activity>, ActivityDefObserver
Provides the components needed to build and run an activity a runtime. The easiest way to build a useful Activity is to extendSimpleActivity.
-
-
Method Summary
Modifier and Type Method Description voidcloseAutoCloseables()Close all autocloseables that have been registered with this Activity.ActionDispensergetActionDispenserDelegate()ActivityControllergetActivityController()ActivityDefgetActivityDef()default java.lang.StringgetAlias()RateLimitergetCycleLimiter()Get the current cycle rate limiter for this activity.RateLimitergetCycleRateLimiter(java.util.function.Supplier<? extends RateLimiter> supplier)Get or create the cycle rate limiter in a safe way.default java.lang.StringgetCycleSummary()InputDispensergetInputDispenserDelegate()ActivityInstrumentationgetInstrumentation()Get or create the instrumentation needed for this activity.OutputDispensergetMarkerDispenserDelegate()MotorDispensergetMotorDispenserDelegate()default ParameterMapgetParams()RateLimitergetPhaseLimiter()Get the current phase rate limiter for this activity.RateLimitergetPhaseRateLimiter(java.util.function.Supplier<? extends RateLimiter> supplier)Get or create the phaseRateLimiterin a concurrent-safe way.IntPredicateDispensergetResultFilterDispenserDelegate()com.codahale.metrics.TimergetResultTimer()RunStategetRunState()RateLimitergetStrideLimiter()Get the current stride rate limiter for this activity.RateLimitergetStrideRateLimiter(java.util.function.Supplier<? extends RateLimiter> supplier)Get or create the strideRateLimiterin a concurrent-safe way.default voidinitActivity()voidregisterAutoCloseable(java.lang.AutoCloseable closeable)Register an object which should be closed after this activity is shutdown.voidsetActionDispenserDelegate(ActionDispenser actionDispenser)voidsetActivityController(ActivityController activityController)Provide the activity with the controls needed to stop itself.voidsetCycleLimiter(RateLimiter rateLimiter)Set the cycle rate limiter for this activity.voidsetInputDispenserDelegate(InputDispenser inputDispenser)voidsetMotorDispenserDelegate(MotorDispenser motorDispenser)voidsetOutputDispenserDelegate(OutputDispenser outputDispenser)voidsetPhaseLimiter(RateLimiter rateLimiter)Set the phase rate limiter for this activity.voidsetResultFilterDispenserDelegate(IntPredicateDispenser resultFilterDispenser)voidsetRunState(RunState runState)voidsetStrideLimiter(RateLimiter rateLimiter)Set the stride rate limiter for this activity.default voidshutdownActivity()-
Methods inherited from interface io.engineblock.activityapi.core.ActivityDefObserver
onActivityDefUpdate
-
-
-
-
Method Detail
-
setActivityController
void setActivityController(ActivityController activityController)
Provide the activity with the controls needed to stop itself.- Parameters:
activityController- The dedicated control interface for this activity
-
getActivityController
ActivityController getActivityController()
-
registerAutoCloseable
void registerAutoCloseable(java.lang.AutoCloseable closeable)
Register an object which should be closed after this activity is shutdown.- Parameters:
closeable- An Autocloseable object
-
getActivityDef
ActivityDef getActivityDef()
-
getAlias
default java.lang.String getAlias()
-
getParams
default ParameterMap getParams()
-
initActivity
default void initActivity()
-
closeAutoCloseables
void closeAutoCloseables()
Close all autocloseables that have been registered with this Activity.
-
getMotorDispenserDelegate
MotorDispenser getMotorDispenserDelegate()
-
setMotorDispenserDelegate
void setMotorDispenserDelegate(MotorDispenser motorDispenser)
-
getInputDispenserDelegate
InputDispenser getInputDispenserDelegate()
-
setInputDispenserDelegate
void setInputDispenserDelegate(InputDispenser inputDispenser)
-
getActionDispenserDelegate
ActionDispenser getActionDispenserDelegate()
-
setActionDispenserDelegate
void setActionDispenserDelegate(ActionDispenser actionDispenser)
-
getResultFilterDispenserDelegate
IntPredicateDispenser getResultFilterDispenserDelegate()
-
setResultFilterDispenserDelegate
void setResultFilterDispenserDelegate(IntPredicateDispenser resultFilterDispenser)
-
getMarkerDispenserDelegate
OutputDispenser getMarkerDispenserDelegate()
-
setOutputDispenserDelegate
void setOutputDispenserDelegate(OutputDispenser outputDispenser)
-
getRunState
RunState getRunState()
-
setRunState
void setRunState(RunState runState)
-
shutdownActivity
default void shutdownActivity()
-
getCycleSummary
default java.lang.String getCycleSummary()
-
getCycleLimiter
RateLimiter getCycleLimiter()
Get the current cycle rate limiter for this activity. The cycle rate limiter is used to throttle the rate at which cycles are dispatched across all threads in the activity- Returns:
- the cycle
RateLimiter
-
setCycleLimiter
void setCycleLimiter(RateLimiter rateLimiter)
Set the cycle rate limiter for this activity. This method should only be used in a non-concurrent context. Otherwise, the supplier versiongetCycleRateLimiter(Supplier)should be used.- Parameters:
rateLimiter- The cycleRateLimiterfor this activity
-
getCycleRateLimiter
RateLimiter getCycleRateLimiter(java.util.function.Supplier<? extends RateLimiter> supplier)
Get or create the cycle rate limiter in a safe way. Implementations should ensure that this method is synchronized or that each requester gets the same cycle rate limiter for the activity.- Parameters:
supplier- ARateLimiterSupplier- Returns:
- An extant or newly created cycle
RateLimiter
-
getStrideLimiter
RateLimiter getStrideLimiter()
Get the current stride rate limiter for this activity. The stride rate limiter is used to throttle the rate at which new strides are dispatched across all threads in an activity.- Returns:
- The stride
RateLimiter
-
setStrideLimiter
void setStrideLimiter(RateLimiter rateLimiter)
Set the stride rate limiter for this activity. This method should only be used in a non-concurrent context. Otherwise, the supplier versiongetStrideRateLimiter(Supplier)} should be used.- Parameters:
rateLimiter- The strideRateLimiterfor this activity.
-
getStrideRateLimiter
RateLimiter getStrideRateLimiter(java.util.function.Supplier<? extends RateLimiter> supplier)
Get or create the strideRateLimiterin a concurrent-safe way. Implementations should ensure that this method is synchronized or that each requester gets the same stride rate limiter for the activity.- Parameters:
supplier- ARateLimiterSupplier- Returns:
- An extant or newly created stride
RateLimiter
-
getPhaseLimiter
RateLimiter getPhaseLimiter()
Get the current phase rate limiter for this activity. The phase rate limiter is used to throttle the rate at which new phases are dispatched across all threads in an activity.- Returns:
- The stride
RateLimiter
-
getResultTimer
com.codahale.metrics.Timer getResultTimer()
-
setPhaseLimiter
void setPhaseLimiter(RateLimiter rateLimiter)
Set the phase rate limiter for this activity. This method should only be used in a non-concurrent context. Otherwise, the supplier versiongetPhaseRateLimiter(Supplier)} should be used.- Parameters:
rateLimiter- The phaseRateLimiterfor this activity.
-
getPhaseRateLimiter
RateLimiter getPhaseRateLimiter(java.util.function.Supplier<? extends RateLimiter> supplier)
Get or create the phaseRateLimiterin a concurrent-safe way. Implementations should ensure that this method is synchronized or that each requester gets the same phase rate limiter for the activity.- Parameters:
supplier- ARateLimiterSupplier- Returns:
- An extant or newly created phase
RateLimiter
-
getInstrumentation
ActivityInstrumentation getInstrumentation()
Get or create the instrumentation needed for this activity. This provides a single place to find and manage, and document instrumentation that is uniform across all activities.- Returns:
- A new or existing instrumentation object for this activity.
-
-