Skip to content

AbstractExecutor

The base class for all executors in CAMS.

Implements the Executor state machine. Subclasses only implement the callbacks onInitialize, onResume, onPause and onDispose; the lifecycle methods themselves cannot be overridden. A synchronous exception in a lifecycle method moves the executor to ExecutorState.Undefined.

Implemented types
Implementers

Constructors

AbstractExecutor

AbstractExecutor<TConfig>()

Properties

configuration

TConfig? get configuration
override

The configuration of this executor as set in initialize.

deployment

SmartphoneDeployment? get deployment
override

The deployment that this executor is part of executing.

measurements

Stream<Measurement> get measurements
override

The stream of Measurement collected by this executor.

samplingState

SamplingState get samplingState
override

The runtime sampling state of this executor.

state

ExecutorState get state
override

The runtime state of this executor.

stateEvents

Stream<ExecutorState> get stateEvents
override

The runtime state changes of this executor.

Methods

addError

void addError(
  1. Object error, [
  2. StackTrace? stacktrace
])

Logs error as a warning and adds it to the measurements stream.

addMeasurement

void addMeasurement(
  1. Measurement measurement
)

Adds measurement to the measurements stream.

dispose

void dispose()
override

Disposes this executor.

If not already paused, pause will be called first.

Once disposed, the executor cannot be used anymore and nothing will happen if any of the life cycle methods are called.

error

void error()

Moves this executor to ExecutorState.Undefined.

initialize

void initialize(
  1. TConfig configuration, [
  2. SmartphoneDeployment? deployment
])
override

Configures and initializes the executor. Call before resume.

onDispose

Future<void> onDispose()

Callback when this executor is disposed.

Subclasses should override this, to implement any cleanup to be done before disposing.

onInitialize

bool onInitialize()

Called by initialize. Returns true if successfully initialized.

If false, the executor stays in ExecutorState.Created. This is a synchronous method and must be light-weight.

onPause

Future<bool> onPause()

Called by pause. Returns true if successfully paused.

If false, the state is not changed.

onResume

Future<bool> onResume()

Called by resume. Returns true if successfully resumed.

If false, the executor moves to ExecutorState.PausedButShouldBeResumed.

pause

void pause()
override

Pauses the executor until resume is called.

pauseButShouldBeResumed

void pauseButShouldBeResumed()
override

Pauses the executor and marks it to be resumed later.

The state becomes ExecutorState.PausedButShouldBeResumed, e.g. when its device is temporarily disconnected.

resume

void resume()
override

Starts or resumes the executor.

toString

String toString()
override

A string representation of this object.

Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.

Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.