diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-04-15 12:06:30 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-04-15 12:06:30 +0300 |
| commit | 3c5f32456c72b26497c05bb35fd64e3c77c6b0f5 (patch) | |
| tree | 4d6b489f02e147e89c23871011512a51daa478fa /Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphDataQueue.cs | |
| parent | 85a6112d2e1eac554cc4cbdfa31cca91d87e6ded (diff) | |
| download | Tango-3c5f32456c72b26497c05bb35fd64e3c77c6b0f5.tar.gz Tango-3c5f32456c72b26497c05bb35fd64e3c77c6b0f5.zip | |
Now using the latest RealTimeGraphX library! + infinity check!
Diffstat (limited to 'Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphDataQueue.cs')
| -rw-r--r-- | Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphDataQueue.cs | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphDataQueue.cs b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphDataQueue.cs new file mode 100644 index 000000000..cb28231ab --- /dev/null +++ b/Software/Visual_Studio/SideChains/RealTimeGraphX-master/RealTimeGraphX/GraphDataQueue.cs @@ -0,0 +1,63 @@ +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 +{ + /// <summary> + /// Represents a blocking concurrent queue for graph data consumption. + /// </summary> + /// <typeparam name="T"></typeparam> + /// <seealso cref="System.Collections.Concurrent.BlockingCollection{T}" /> + public class GraphDataQueue<T> : BlockingCollection<T> + { + /// <summary> + /// Initializes a new instance of the GraphDataQueue, Use Add and TryAdd for Enqueue and TryEnqueue and Take and TryTake for Dequeue and TryDequeue functionality + /// </summary> + public GraphDataQueue() + : base(new ConcurrentQueue<T>()) + { + } + + /// <summary> + /// Initializes a new instance of the GraphDataQueue, Use Add and TryAdd for Enqueue and TryEnqueue and Take and TryTake for Dequeue and TryDequeue functionality + /// </summary> + /// <param name="maxSize"></param> + public GraphDataQueue(int maxSize) + : base(new ConcurrentQueue<T>(), maxSize) + { + } + + /// <summary> + /// Enqueues the specified item. + /// </summary> + /// <param name="item">The item.</param> + public void BlockEnqueue(T item) + { + Add(item); + } + + /// <summary> + /// Blocks until an item is available for dequeuing. + /// </summary> + /// <returns></returns> + public T BlockDequeue() + { + return Take(); + } + + /// <summary> + /// Blocks until an item is available for dequeuing. + /// </summary> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns></returns> + public T BlockDequeue(CancellationToken cancellationToken) + { + return Take(cancellationToken); + } + } +} |
