diff --git a/Source/HiveMQtt/Client/internal/AwaitableQueueX.cs b/Source/HiveMQtt/Client/internal/AwaitableQueueX.cs
index 16ee266c..c992f85f 100644
--- a/Source/HiveMQtt/Client/internal/AwaitableQueueX.cs
+++ b/Source/HiveMQtt/Client/internal/AwaitableQueueX.cs
@@ -5,23 +5,45 @@ namespace HiveMQtt.Client.Internal;
using System.Threading;
using System.Threading.Tasks;
+///
+/// A queue that can be awaited for items to be enqueued.
+///
+/// The type of items to queue.
public class AwaitableQueueX : IDisposable
{
+ ///
+ /// The semaphore used to signal when items are enqueued.
+ ///
private readonly SemaphoreSlim semaphore;
+
+ ///
+ /// The internal queue of items.
+ ///
private readonly ConcurrentQueue queue;
+ ///
+ /// Initializes a new instance of the class.
+ ///
public AwaitableQueueX()
{
this.semaphore = new SemaphoreSlim(0);
this.queue = new ConcurrentQueue();
}
+ ///
+ /// Enqueues an item.
+ ///
+ /// The item to enqueue.
public void Enqueue(T item)
{
this.queue.Enqueue(item);
this.semaphore.Release();
}
+ ///
+ /// Enqueues a range of items.
+ ///
+ /// The items to enqueue.
public void EnqueueRange(IEnumerable source)
{
var n = 0;
@@ -34,6 +56,11 @@ public void EnqueueRange(IEnumerable source)
this.semaphore.Release(n);
}
+ ///
+ /// Dequeues an item.
+ ///
+ /// The cancellation token.
+ /// The dequeued item.
public async Task DequeueAsync(CancellationToken cancellationToken)
{
while (true)
@@ -47,6 +74,9 @@ public async Task DequeueAsync(CancellationToken cancellationToken)
}
}
+ ///
+ /// Clears the queue.
+ ///
public void Clear()
{
while (this.queue.TryDequeue(out _))
@@ -55,10 +85,18 @@ public void Clear()
}
}
+ ///
+ /// Gets the number of items in the queue.
+ ///
+ /// The number of items in the queue.
public int Count => this.queue.Count;
+ ///
+ /// Gets a value indicating whether the queue is empty.
+ ///
public bool IsEmpty => this.queue.IsEmpty;
+ ///
public void Dispose()
{
this.semaphore.Dispose();