/// <summary> /// Removes completed batch from the head of the queue /// </summary> /// <param name="token">Cancellation token</param> /// <returns>The batch removed from queue</returns> /// <exception cref="OperationCanceledException">Cancellation was requested by token</exception> /// <exception cref="ObjectDisposedException">Queue was disposed</exception> public T[] Take(CancellationToken token) { bool takeResult = TryTakeInner(out T[] result, Timeout.Infinite, token); TurboContract.Assume(takeResult, "takeResult is false when timeout is Infinite"); return(result); }
/// <summary> /// Adds the item to the tail of the queue /// </summary> /// <param name="item">New item</param> /// <param name="token">Cancellation token</param> /// <exception cref="OperationCanceledException">Cancellation was requested by token</exception> /// <exception cref="ObjectDisposedException">Queue was disposed</exception> public void Add(T item, CancellationToken token) { bool addResult = TryAddInner(item, Timeout.Infinite, token); TurboContract.Assume(addResult, "addResult is false when timeout is Infinite"); }