diff --git a/NxGraph/Fsm/Async/AsyncRelayState.cs b/NxGraph/Fsm/Async/AsyncRelayState.cs index cc65955..412fbbd 100644 --- a/NxGraph/Fsm/Async/AsyncRelayState.cs +++ b/NxGraph/Fsm/Async/AsyncRelayState.cs @@ -9,7 +9,7 @@ public sealed class AsyncRelayState( Func> run, Func>? onEnter = null, - Func? onExit = null) + Func>? onExit = null) : AsyncState { private readonly Func> _run = run ?? throw new ArgumentNullException(nameof(run)); @@ -24,9 +24,9 @@ protected override ValueTask OnRunAsync(CancellationToken ct) return _run(ct); } - protected override ValueTask OnExitAsync(CancellationToken ct) + protected override ValueTask OnExitAsync(CancellationToken ct) { - return onExit?.Invoke(ct) ?? default; + return onExit?.Invoke(ct) ?? ResultHelpers.Success; } } @@ -40,7 +40,7 @@ protected override ValueTask OnExitAsync(CancellationToken ct) public sealed class AsyncRelayState( Func> run, Func>? onEnter = null, - Func? onExit = null) + Func>? onExit = null) : AsyncState { private readonly Func> _run = run ?? throw new ArgumentNullException(nameof(run)); @@ -55,8 +55,8 @@ protected override ValueTask OnRunAsync(CancellationToken ct) return _run(Agent, ct); } - protected override ValueTask OnExitAsync(CancellationToken ct) + protected override ValueTask OnExitAsync(CancellationToken ct) { - return onExit?.Invoke(Agent, ct) ?? default; + return onExit?.Invoke(Agent, ct) ?? ResultHelpers.Success; } } \ No newline at end of file diff --git a/NxGraph/Fsm/Async/AsyncState.cs b/NxGraph/Fsm/Async/AsyncState.cs index d2c85e0..30986ec 100644 --- a/NxGraph/Fsm/Async/AsyncState.cs +++ b/NxGraph/Fsm/Async/AsyncState.cs @@ -48,9 +48,9 @@ protected virtual ValueTask OnRunAsync(CancellationToken ct) return ResultHelpers.Continue; } - protected virtual ValueTask OnExitAsync(CancellationToken ct) + protected virtual ValueTask OnExitAsync(CancellationToken ct) { - return default; + return ResultHelpers.Success; } } diff --git a/NxGraph/Fsm/Async/AsyncStateMachine.cs b/NxGraph/Fsm/Async/AsyncStateMachine.cs index d56a24f..fa87de0 100644 --- a/NxGraph/Fsm/Async/AsyncStateMachine.cs +++ b/NxGraph/Fsm/Async/AsyncStateMachine.cs @@ -211,13 +211,13 @@ await TransitionTo(result == Result.Success ? ExecutionStatus.Completed : Execut } } - protected override ValueTask OnExitAsync(CancellationToken ct) + protected override ValueTask OnExitAsync(CancellationToken ct) { // For Ignore policy, OnEnterAsync returns early with the gate held. // We want OnRunAsync to run and return the terminal result, and then // OnExitAsync will release the gate in the normal way. Volatile.Write(ref _executeGate, 0); - return ResultHelpers.CompletedTask; + return ResultHelpers.Success; } private async ValueTask InternalRunAsync(CancellationToken ct) @@ -239,8 +239,8 @@ private async ValueTask InternalRunAsync(CancellationToken ct) } } - LogicNode logicLogicNode = (LogicNode)node; - Result result = await logicLogicNode.AsyncLogic.ExecuteAsync(ct).ConfigureAwait(false); + LogicNode logic = (LogicNode)node; + Result result = await logic.AsyncLogic.ExecuteAsync(ct).ConfigureAwait(false); switch (result.Code) { case Result.StatusCode.Success: @@ -252,7 +252,7 @@ private async ValueTask InternalRunAsync(CancellationToken ct) NodeId next; - if (logicLogicNode.AsyncLogic is IAsyncDirector director) + if (logic.AsyncLogic is IAsyncDirector director) { next = await director.SelectNextAsync(ct).ConfigureAwait(false); if (next.Equals(NodeId.Default))