public override V Complete() { if (!done) { queue.ReleaseWrite(valueToPut); return(successfulPut); } else { throw new InvalidOperationException("Put: Complete or Cancel can be called only once"); } }
public static async Task Enqueue <T>(this IQueueSink <T> queue, T item, CancellationToken ctoken) { AcquireWriteResult result = await queue.AcquireWriteAsync(1, ctoken); result.Visit <DBNull> ( new Func <AcquireWriteSucceeded, DBNull> ( succeeded => { System.Diagnostics.Debug.Assert(succeeded.ItemCount == 1); bool wasCancelled = false; if (ctoken.IsCancellationRequested) { wasCancelled = true; queue.ReleaseWrite(); } else { queue.ReleaseWrite(item); } if (wasCancelled) { throw new OperationCanceledException(ctoken); } return(DBNull.Value); } ), new Func <AcquireWriteCancelled, DBNull> ( cancelled => { throw new OperationCanceledException(ctoken); } ), new Func <AcquireWriteFaulted, DBNull> ( faulted => { throw faulted.Exception; } ) ); }
public static void ReleaseWrite <T>(this IQueueSink <T> queue, T producedItem) { queue.ReleaseWrite(ImmutableList <T> .Empty.Add(producedItem)); }
public static void ReleaseWrite <T>(this IQueueSink <T> queue) { queue.ReleaseWrite(ImmutableList <T> .Empty); }