Esempio n. 1
0
        protected T GetSingleConsumerNodeValue(LinkedQueueNode <T> currConsumerNode, LinkedQueueNode <T> nextNode)
        {
            // we have to null out the value because we are going to hang on to the node
            T nextValue = nextNode.GetAndNullValue();

            // Fix up the next ref of currConsumerNode to prevent promoted nodes from keep new ones alive.
            // We use a reference to self instead of null because null is already a meaningful value (the next of
            // producer node is null).
            currConsumerNode.SoNext(currConsumerNode);
            this.SpConsumerNode(nextNode);

            // currConsumerNode is now no longer referenced and can be collected
            return(nextValue);
        }