Class (GI Struct)

Dex-1DexStateTransitionContextAbstractSince 1.2

Dex.StateTransitionContext is an opaque per-callback structure with information and state access for a Dex.StateTransition callback.

It is only valid for the duration of the callback and must not be stored.

Dex.StateTransitionContext.get_from and Dex.StateTransitionContext.get_to return the declared edge that caused the callback to run. Dex.StateTransitionContext.get_state and Dex.StateTransitionContext.set_state access the real state in the Dex.StateMachine. Use Dex.StateTransitionContext.continue_to to follow another declared edge before queued transition requests are processed.

1.2

Index
  • Attempts to continue from the current transition to target immediately.

    The continuation runs while the state machine still holds its internal serialization slot, so queued Dex.StateMachine.transition requests are not processed first. If context has not explicitly set the state with Dex.StateTransitionContext.set_state, the current edge target is committed before the next edge is executed.

    The next transition callback is called before this function returns. If that callback uses dex_await(), the same transition fiber suspends and resumes, while the state machine still holds the serialization slot. Chained continuations therefore use the normal C call stack and should be reserved for short, bounded chains rather than unbounded graph traversal.

    The next edge is looked up from the real current state to target. If no such edge exists, false is returned and error is set to Dex.Error.INVALID_TRANSITION. If the next edge callback fails, its error is propagated.

    Parameters

    • target: number

      the target state for the next edge

    Returns boolean

    true if the continuation succeeded; otherwise false

    1.2

    GLib.Error

  • Gets the source state for the transition edge being executed.

    This value is fixed for the lifetime of context and does not change if Dex.StateTransitionContext.set_state is called.

    Returns number

    the source state for the transition edge

    1.2

  • Gets the target state for the transition edge being executed.

    This value is fixed for the lifetime of context and does not change if Dex.StateTransitionContext.set_state is called.

    Returns number

    the target state for the transition edge

    1.2

  • Sets the real current state in the Dex.StateMachine.

    This may be used by transition callbacks to expose intermediate states while doing asynchronous work. state must be a valid value in the state machine's enum type. This method may only be used while the transition callback is active.

    Parameters

    • state: number

      the new state

    Returns void

    1.2

  • Creates a future that resolves when the active transition context is interrupted.

    This is a cooperative mechanism for long-running transition callbacks. The returned future resolves to true when Dex.StateMachine.interrupt is called while context is active. If the context was already interrupted before this function is called, the returned future is already resolved.

    If context completes before it is interrupted, the returned future is rejected with Gio.IOErrorEnum.CANCELLED.

    Returns Dex.Future

    a future resolving to true when interrupted

    1.2