using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace RealTimeGraphX
{
///
/// Represents a blocking concurrent queue for graph data consumption.
///
///
///
public class GraphDataQueue : BlockingCollection
{
///
/// Initializes a new instance of the GraphDataQueue, Use Add and TryAdd for Enqueue and TryEnqueue and Take and TryTake for Dequeue and TryDequeue functionality
///
public GraphDataQueue()
: base(new ConcurrentQueue())
{
}
///
/// Initializes a new instance of the GraphDataQueue, Use Add and TryAdd for Enqueue and TryEnqueue and Take and TryTake for Dequeue and TryDequeue functionality
///
///
public GraphDataQueue(int maxSize)
: base(new ConcurrentQueue(), maxSize)
{
}
///
/// Enqueues the specified item.
///
/// The item.
public void BlockEnqueue(T item)
{
Add(item);
}
///
/// Blocks until an item is available for dequeuing.
///
///
public T BlockDequeue()
{
return Take();
}
///
/// Blocks until an item is available for dequeuing.
///
/// The cancellation token.
///
public T BlockDequeue(CancellationToken cancellationToken)
{
return Take(cancellationToken);
}
}
}