diff options
Diffstat (limited to 'lib/Utils')
-rw-r--r-- | lib/Utils/src/Async/AsyncQueue.cs | 4 | ||||
-rw-r--r-- | lib/Utils/src/Async/IAsyncQueue.cs | 11 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/Utils/src/Async/AsyncQueue.cs b/lib/Utils/src/Async/AsyncQueue.cs index ddd2da5..a64733f 100644 --- a/lib/Utils/src/Async/AsyncQueue.cs +++ b/lib/Utils/src/Async/AsyncQueue.cs @@ -104,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> @@ -121,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> |