/// <summary> /// Unlinks the given node from producer queue. Symmetric to /// <see cref="UnlinkCancelledConsumer"/>. /// </summary> private void UnlinkCancelledProducer(Node node) { if (_waitingProducers.ShouldUnlink(node)) { using (_qlock.Lock()) { if (_waitingProducers.ShouldUnlink(node)) { _waitingProducers.Unlink(node); } } } }
/// <summary> /// Unlinks the given node from consumer queue. Called by cancelled /// (timeout, interrupt) waiters to avoid garbage retention in the /// absence of producers. /// </summary> private void UnlinkCancelledConsumer(Node node) { // Use a form of double-check to avoid unnecessary locking and // traversal. The first check outside lock might // conservatively report true. if (_waitingConsumers.ShouldUnlink(node)) { using (_qlock.Lock()) { if (_waitingConsumers.ShouldUnlink(node)) { _waitingConsumers.Unlink(node); } } } }