StateQueue

Let f(x) be an expensive operation which changes something to (or towards) state x. At most one f call may be in progress at any time. This type orchestrates a series of operations that eventually bring the state to some goal, while allowing the goal to change at any time.

Constructors

this
this()
Undocumented in source.
this
this(Promise!State delegate(State) stateFunc, State initialState)

Constructor.

Members

Functions

setCurrentState
void setCurrentState(State state)

Can be used to indicate that the state has been changed externally (e.g. to some "invalid"/"dirty" state). If a transition operation is already in progress, assume that it will change the state to the given state instead of its actual goal.

setGoal
Promise!void setGoal(State state)

Set the goal state. Starts off a transition operation if needed. Returns a promise that will be fulfilled when we reach the goal state, or rejected if the goal state changes before it is reached.

Variables

currentTransition
Promise!void currentTransition;

The current state transition.

goalPromise
Promise!void goalPromise;

The promise that will be fulfilled when we reach the goal state.

goalState
State goalState;

The final state that we want to be in.

newState
State newState;

The state that any current change is moving towards.

oldState
State oldState;

The state that any current change is moving away from.

stateFunc
Promise!State delegate(State) stateFunc;

The asynchronous implementation function which actually changes the state.

Meta