SimpleMultithreadQueue 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SimpleMultithreadQueue --version 1.0.0                
NuGet\Install-Package SimpleMultithreadQueue -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SimpleMultithreadQueue" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleMultithreadQueue --version 1.0.0                
#r "nuget: SimpleMultithreadQueue, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 queues
  • bool 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 status
  • MultithreadQueue<T> R_PopToNewQueue() - returns new MultithreadQueue with all elements and clears current queues
  • Queue<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 their
  • void R_Clear() clears MultithreadQueue
  • bool 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 empty
  • T R_Dequeue_Wait(int timoutMs = -1) - get next element or wait for a new one. timoutMs = -1 is infinity time to wait
  • bool R_CheckMayHaveNew() - returns true if queue can contain new element, never returns false, if queue isn't empty
  • void Wait(int timoutMs = -1) - wait for new element. timoutMs = -1 is infinity time to wait
  • public 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .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.

Version Downloads Last updated
1.0.1 511 5/16/2021
1.0.0 334 5/12/2021