aboutsummaryrefslogtreecommitdiff
path: root/lib/Utils/src/Async
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Utils/src/Async')
-rw-r--r--lib/Utils/src/Async/AsyncQueue.cs8
-rw-r--r--lib/Utils/src/Async/IAsyncQueue.cs11
2 files changed, 16 insertions, 3 deletions
diff --git a/lib/Utils/src/Async/AsyncQueue.cs b/lib/Utils/src/Async/AsyncQueue.cs
index e94d08e..a64733f 100644
--- a/lib/Utils/src/Async/AsyncQueue.cs
+++ b/lib/Utils/src/Async/AsyncQueue.cs
@@ -60,7 +60,9 @@ namespace VNLib.Utils.Async
/// </summary>
/// <param name="singleWriter">A value that specifies only a single thread be enqueing items?</param>
/// <param name="singleReader">A value that specifies only a single thread will be dequeing</param>
- /// <param name="capacity">The maxium number of items to enque without failing</param>
+ /// <param name="capacity">
+ /// The maxium number of items to enque without failing. If set to <see cref="int.MaxValue"/> maximum is disabled
+ /// </param>
public AsyncQueue(bool singleWriter, bool singleReader, int capacity = int.MaxValue)
{
if(capacity == int.MaxValue)
@@ -102,7 +104,7 @@ namespace VNLib.Utils.Async
public AsyncQueue(BoundedChannelOptions options) => _channel = Channel.CreateBounded<T>(options);
/// <inheritdoc/>
- public bool TryEnque(T item) => _channel.Writer.TryWrite(item);
+ public bool TryEnqueue(T item) => _channel.Writer.TryWrite(item);
/// <inheritdoc/>
/// <exception cref="ObjectDisposedException"></exception>
@@ -119,5 +121,7 @@ namespace VNLib.Utils.Async
/// <inheritdoc/>
/// <exception cref="ObjectDisposedException"></exception>
public bool TryPeek([MaybeNullWhen(false)] out T result) => _channel.Reader.TryPeek(out result);
+
+ bool IAsyncQueue<T>.TryEnque(T item) => TryEnqueue(item);
}
}
diff --git a/lib/Utils/src/Async/IAsyncQueue.cs b/lib/Utils/src/Async/IAsyncQueue.cs
index ab786f1..677f34f 100644
--- a/lib/Utils/src/Async/IAsyncQueue.cs
+++ b/lib/Utils/src/Async/IAsyncQueue.cs
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2023 Vaughn Nugent
+* Copyright (c) 2024 Vaughn Nugent
*
* Library: VNLib
* Package: VNLib.Utils
@@ -22,6 +22,7 @@
* along with VNLib.Utils. If not, see http://www.gnu.org/licenses/.
*/
+using System;
using System.Threading;
using System.Threading.Tasks;
using System.Diagnostics.CodeAnalysis;
@@ -41,6 +42,14 @@ namespace VNLib.Utils.Async
/// </summary>
/// <param name="item">The item to eqneue</param>
/// <returns>True if the queue can accept another item, false otherwise</returns>
+ bool TryEnqueue(T item);
+
+ /// <summary>
+ /// Attemts to enqueue an item if the queue has the capacity
+ /// </summary>
+ /// <param name="item">The item to eqneue</param>
+ /// <returns>True if the queue can accept another item, false otherwise</returns>
+ [Obsolete("Use TryEnqueue instead")]
bool TryEnque(T item);
/// <summary>