private uint guardedRegionsCounter; // number of entries into try-clause private AsyncStateMachine(Transition <TState, AsyncStateMachine <TState> > transition, TState state) { builder = AsyncValueTaskMethodBuilder.Create(); this.transition = transition; State = state; StateId = IAsyncStateMachine <TState> .FinalState; exception = null; guardedRegionsCounter = 0; }
private uint guardedRegionsCounter; //number of entries into try-clause private AsyncStateMachine(Transition transition, STATE state) { builder = AsyncValueTaskMethodBuilder.Create(); this.transition = transition; State = state; StateId = FINAL_STATE; exception = null; guardedRegionsCounter = 0; }
private AsyncStateMachine(Transition <TState, AsyncStateMachine <TState, TResult> > transition, TState state) { builder = AsyncValueTaskMethodBuilder <TResult> .Create(); StateId = IAsyncStateMachine <TState> .FinalState; State = state; this.transition = transition; guardedRegionsCounter = 0; exception = null; result = default; }
// RESULTS // M1Async and M2Async : exact same assembly code // M1AsyncAsyncA, M1AsyncAsyncB and M2AsyncASync : exact same assembly code // (heavy usage of the state machine) // so the diff is in the state machine // // M1AsyncAsyncA // ValueTask<int> valueTask = (c.FAsync != null) ? c.FAsync() : default(ValueTask<int>); // awaiter = valueTask.GetAwaiter(); // // M2AsyncAsync // Func<ValueTask<int>> fAsync = c.FAsync; // ValueTask<int> valueTask = (fAsync != null) ? fAsync() : default(ValueTask<int>); // awaiter = valueTask.GetAwaiter(); // // M1AsyncAsyncB // if (c.FAsync == null) { result = 0; done; } // awaiter = c.FAsync().GetAwaiter(); // // assembly level, M1AsyncAsyncA and M2AsyncAsync are practically equivalent // assembly level, M1AsyncAsyncB is marginally simpler private ValueTask <int> M1AsyncAsyncA__generated() { M1AsyncAsyncA__d__5 stateMachine = default(M1AsyncAsyncA__d__5); stateMachine.__4__this = this; stateMachine.__t__builder = AsyncValueTaskMethodBuilder <int> .Create(); stateMachine.__1__state = -1; AsyncValueTaskMethodBuilder <int> __t__builder = stateMachine.__t__builder; __t__builder.Start(ref stateMachine); return(stateMachine.__t__builder.Task); }
[EditorBrowsable(EditorBrowsableState.Never)] // intended only for compiler consumption #endif public static AsyncValueTaskMethodBuilder <TResult> CreateAsyncMethodBuilder() => AsyncValueTaskMethodBuilder <TResult> .Create();
private protected ValueTaskCompletionSource() { builder = AsyncValueTaskMethodBuilder <ValueTask <TResult> > .Create(); completed = new AtomicBoolean(false); }
[EditorBrowsable(EditorBrowsableState.Never)] // intended only for compiler consumption public static AsyncValueTaskMethodBuilder <TResult> CreateAsyncMethodBuilder() { return(AsyncValueTaskMethodBuilder <TResult> .Create()); }