SimpleMultithreadQueue 1.0.0
See the version list below for details.
dotnet add package SimpleMultithreadQueue --version 1.0.0
NuGet\Install-Package SimpleMultithreadQueue -Version 1.0.0
<PackageReference Include="SimpleMultithreadQueue" Version="1.0.0" />
paket add SimpleMultithreadQueue --version 1.0.0
#r "nuget: SimpleMultithreadQueue, 1.0.0"
// Install SimpleMultithreadQueue as a Cake Addin #addin nuget:?package=SimpleMultithreadQueue&version=1.0.0 // Install SimpleMultithreadQueue as a Cake Tool #tool nuget:?package=SimpleMultithreadQueue&version=1.0.0
SimpleMultithreadQueue
Queue for multithread programs with one queue reader and several writers
How it works
MultithreadQueue<T> contains two objects Queue<T> one is an active queue (current queue) and one is a buffer While read thread doesn't pops elements from MultithreadQueue, write threads adds new elements to activeQueue. When read thread requires new element, algorithm checks, if bufferQueue has elements, pops from bufferQueue, swaps queues else and pops from new buffer (empty bufferQueue becames activeQueue to receive new elements), else returns default and false.
Methods
For writers
Enqueue({Element])
- add element to queue
For readers
Only reader's thread methods marked by prefix "R_"
void R_Swap()
- swaps active and buffer queuesbool R_DequeueReady(out T nextObj, bool swapAutomatically = true)
- nextObj - next element in bufferQueue, swapAutomatically - flag to swap queues (returns element only from bufferQueue if the bufferQueue is empty, swaps queues and returns default and false)bool R_Dequeue(out T nextObj)
- deq dequeues next element (default) and returns success statusMultithreadQueue<T> R_PopToNewQueue()
- returns new MultithreadQueue with all elements and clears current queuesQueue<T> R_PopAllToNewQueue()
- returns queue with all elements on the call time.IEnumerable<T> R_PopAll()
pops all elements from queue with enumerable (can be used in foreach cycle) and dequeue theirvoid R_Clear()
clears MultithreadQueuebool R_IsEmpty
check if the MultithreadQueue is empty
Experemental reader wait for new elemtns methods
Queue<T> R_PopAllToNewQueue_Wait(int timoutMs = -1)
- returns all elements on the call time or waits for new elements if emptyT R_Dequeue_Wait(int timoutMs = -1)
- get next element or wait for a new one. timoutMs = -1 is infinity time to waitbool R_CheckMayHaveNew()
- returns true if queue can contain new element, never returns false, if queue isn't emptyvoid Wait(int timoutMs = -1)
- wait for new element. timoutMs = -1 is infinity time to waitpublic WaitHandle NewElementWaiter { get; }
- property to get new element WaitHandle
Also MultithreadQueue<T> implements IEnumerator<T> interface and can be used in foreach cycles (without elements dequeue)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.