Class ThreadSafeQueue<T>
Only use this collection when absolutely necessary when you can't use System.Collections.Concurrent.ConcurrentQueue<> instead.
It known to have very bad performance and memory usage for often updated big collections, because all new elements added to stack which then reversed when you need to dequeue element.
Inheritance
System.Object
ThreadSafeQueue<T>
Implements
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
Assembly: Eco.Core.dll
Syntax
public class ThreadSafeQueue<T> : Object, IEnumerable<T>, IEnumerable
Type Parameters
Constructors
ThreadSafeQueue()
Declaration
ThreadSafeQueue(IEnumerable<T>)
Declaration
public ThreadSafeQueue(IEnumerable<T> items)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<T> |
items |
|
Properties
IsEmpty
Declaration
public bool IsEmpty { get; }
Property Value
Type |
Description |
System.Boolean |
|
Snapshot
Declaration
public ImmutableQueue<T> Snapshot { get; }
Property Value
Type |
Description |
System.Collections.Immutable.ImmutableQueue<T> |
|
Methods
Clear()
Declaration
public virtual void Clear()
Dequeue()
Declaration
Returns
Enqueue(T)
Declaration
public void Enqueue(T item)
Parameters
Type |
Name |
Description |
T |
item |
|
GetEnumerator()
Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type |
Description |
System.Collections.Generic.IEnumerator<T> |
|
Peek()
Declaration
Returns
TryDequeue(out T)
Declaration
public bool TryDequeue(out T item)
Parameters
Type |
Name |
Description |
T |
item |
|
Returns
Type |
Description |
System.Boolean |
|
TryDequeue(Func<T, Boolean>, out T)
Tries to dequeue item from the ThreadSafeQueue<T> if it is matching predicate
.
It is atomic thread-safe alternative of sequence
if (!queue.IsEmpty && predicate(queue.Peek())) value = queue.Dequeue();
Declaration
public bool TryDequeue(Func<T, bool> predicate, out T item)
Parameters
Type |
Name |
Description |
System.Func<T, System.Boolean> |
predicate |
|
T |
item |
|
Returns
Type |
Description |
System.Boolean |
|
Implements
System.Collections.Generic.IEnumerable<>
System.Collections.IEnumerable
Extension Methods