Ejemplo n.º 1
0
 public bool _RestartWith(CompletionLink next)
 {
     if (Interlocked.CompareExchange(ref this.next, next, null) != null)
     {
         return(false);
     }
     else
     {
         cancellationTokenSource.Cancel();
         try {
             task?.Wait();
         } catch (AggregateException aggregateException) {
             if (aggregateException.InnerExceptions.Count != 1 ||
                 !(aggregateException.InnerExceptions[0] is TaskCanceledException))
             {
                 throw;
             }
         }
         if (!isCompletedUninterrupted)
         {
             this.next     = next;
             next.previous = this;
         }
         return(true);
     }
 }
Ejemplo n.º 2
0
 public void StartNext(CompletionLink next) {
    var spinner = new SpinWait();
    while (!current._RestartWith(next)) {
       spinner.SpinOnce();
    }
    next._Start();
    current = next;
 }
Ejemplo n.º 3
0
        public void StartNext(CompletionLink next)
        {
            var spinner = new SpinWait();

            while (!current._RestartWith(next))
            {
                spinner.SpinOnce();
            }
            next._Start();
            current = next;
        }
Ejemplo n.º 4
0
 private void HandleCompletion()
 {
     previous?.HandleCompletion();
     completionHandlers.ForEach(x => x.Invoke());
     completionLatch.Set();
     if (this.previous != null)
     {
         this.previous.next = null;
         this.previous      = null;
     }
     this.completionHandlers.Clear();
 }
Ejemplo n.º 5
0
 public bool _RestartWith(CompletionLink next) {
    if (Interlocked.CompareExchange(ref this.next, next, null) != null) {
       return false;
    } else {
       cancellationTokenSource.Cancel();
       try {
          task?.Wait();
       } catch (AggregateException aggregateException) {
          if (aggregateException.InnerExceptions.Count != 1 ||
              !(aggregateException.InnerExceptions[0] is TaskCanceledException)) {
             throw;
          }
       }
       if (!isCompletedUninterrupted) {
          this.next = next;
          next.previous = this;
       }
       return true;
    }
 }
Ejemplo n.º 6
0
 public CompletionChain(Func <CancellationToken, bool> action)
 {
     this.action  = action;
     this.current = new CompletionLink(this, true, "_sentinel_link_", (cancellationToken) => true);
 }
Ejemplo n.º 7
0
 public CompletionChain(Func<CancellationToken, bool> action) {
    this.action = action;
    this.current = new CompletionLink(this, true, "_sentinel_link_", (cancellationToken) => true);
 }
Ejemplo n.º 8
0
 private void HandleCompletion() {
    previous?.HandleCompletion();
    completionHandlers.ForEach(x => x.Invoke());
    completionLatch.Set();
    if (this.previous != null) {
       this.previous.next = null;
       this.previous = null;
    }
    this.completionHandlers.Clear();
 }