示例#1
0
 private static async Task Track(TimeSpan timeout, IAsyncEvent refreshEvent, Action candidateState, CancellationToken token)
 {
     //spin loop to wait for the timeout
     while (await refreshEvent.Wait(timeout, token).ConfigureAwait(false))
     {
     }
     //timeout happened, move to candidate state
     candidateState();
 }
示例#2
0
 Task IChannelReader <TOutput> .WaitToReadAsync(CancellationToken token)
 => readTrigger.Wait(token);
示例#3
0
 /// <summary>
 /// Turns caller into idle state until the current event is set.
 /// </summary>
 /// <remarks>
 /// This method can potentially blocks execution of async flow infinitely.
 /// </remarks>
 /// <param name="event">An event to synchronize with.</param>
 /// <returns>A promise of signaled state.</returns>
 public static Task Wait(this IAsyncEvent @event) => @event.Wait(CancellationToken.None);
示例#4
0
 /// <summary>
 /// Turns caller into idle state until the current event is set.
 /// </summary>
 /// <remarks>
 /// This method can potentially blocks execution of async flow infinitely.
 /// </remarks>
 /// <param name="event">An event to synchronize with.</param>
 /// <param name="token">The token that can be used to abort wait process.</param>
 /// <returns>A promise of signaled state.</returns>
 public static Task Wait(this IAsyncEvent @event, CancellationToken token) => @event.Wait(InfiniteTimeSpan, token);
示例#5
0
 /// <summary>
 /// Turns caller into idle state until the current event is set.
 /// </summary>
 /// <param name="event">An event to synchronize with.</param>
 /// <param name="timeout">The interval to wait for the signaled state.</param>
 /// <returns><see langword="true"/> if signaled state was set; otherwise, <see langword="false"/>.</returns>
 public static Task <bool> Wait(this IAsyncEvent @event, TimeSpan timeout) => @event.Wait(timeout, CancellationToken.None);
示例#6
0
 internal static async Task WaitForCommitAsync(IAuditTrail log, IAsyncEvent commitEvent, long index, TimeSpan timeout, CancellationToken token)
 {
     for (var timeoutMeasurement = new Timeout(timeout); log.GetLastIndex(true) < index; await commitEvent.Wait(timeout, token).ConfigureAwait(false))
     {
         timeoutMeasurement.ThrowIfExpired(out timeout);
     }
 }