Esempio n. 1
0
 /// <summary>Attempts to remove an item from the start of the queue.</summary>
 /// <param name="item">The item dequeued if successful.</param>
 /// <returns>True if the operation succeeds, false if the queue was empty.</returns>
 public bool TryDequeue(out T item)
 {
     if (_backing.TryDequeue(out item))
     {
         Interlocked.Decrement(ref _count);
         return(true);
     }
     return(false);
 }
Esempio n. 2
0
 /// <summary>Moves to the next item in the enumeration (removing it from the queue).</summary>
 /// <returns>True if the method succeeds, false if the queue was empty.</returns>
 /// <remarks>Since the class refers to the live state of the queue, after returning false
 /// it may return true on a subsequent call, if items were added in the meantime.</remarks>
 public bool MoveNext()
 {
     return(_queue.TryDequeue(out _current));
 }
Esempio n. 3
0
 /// <summary>Attempt to remove a single item, obtaining the item.</summary>
 /// <returns>True if an item was removed, false if the collection was empty.</returns>
 /// <param name="item">The item removed.</param>
 public bool TryTake(out T item)
 {
     return(_backing.TryDequeue(out item));
 }