Skip to content

Instantly share code, notes, and snippets.

@Acapla
Acapla / simpleAwaitableQueue
Created January 22, 2014 07:59
simple awaitable queue
public class AwaitableQueue<T>
{
private readonly ConcurrentQueue<T> _queue = new ConcurrentQueue<T>();
private long _count = 0;
private readonly ConcurrentQueue<TaskCompletionSource<T>> _pending = new ConcurrentQueue<TaskCompletionSource<T>>();
/// <summary>
/// Enqueue the specified item. Blocking operation.
/// </summary>
/// <param name="item">Item.</param>