/// <summary> /// Consume one element, will block if queue is empty /// Only one consumer at a time is allowed /// </summary> /// <param name="consumer">the consumer callback object</param> /// <exception cref="System.Exception"/> internal virtual void Consume(SinkQueue.Consumer <T> consumer) { T e = WaitForData(); try { consumer.Consume(e); // can take forever _dequeue(); } finally { ClearConsumerLock(); } }
/// <summary>Consume all the elements, will block if queue is empty</summary> /// <param name="consumer">the consumer callback object</param> /// <exception cref="System.Exception"/> internal virtual void ConsumeAll(SinkQueue.Consumer <T> consumer) { WaitForData(); try { for (int i = Size(); i-- > 0;) { consumer.Consume(Front()); // can take forever _dequeue(); } } finally { ClearConsumerLock(); } }