Hello,
I have updated my scalable and relaxed MPMC priority Queue to
version 1.02, now it is working correctly in both the push() and the pop() side and i have tested it myself and it is now working correctly...
But there is a mandatory requirement: The number of consumer threads must be equal or greater to the number of queues that you pass to the constructor.
Author: Amine Moulay Ramdane
Language: FPC Pascal v2.2.0+ / Delphi 5+:
http://www.freepascal.org/Operating Systems: Win , Linux and Mac (x86).
Description:
A scalable and relaxed MPMC priority Queue.
Relaxed means not a strict FIFO, but even if it's not a strict FIFO it processes the jobs in a FIFO order in each queue, that's also interresting.
Where can my scalable and relaxed MPMC priority Queue be useful ?
When for example you want to do something like a threadpool that do parallel tasks without the need that the queue be strict FIFO, and you can find that in many applications that do parallel mathematical calculations or parallel mechanical or graphic calculations and many parallel tasks... so you will reduce on those applications the S part in the Amdahl equation using my scalable and relaxed MPMC priority Queue.
The number of consumer threads must be equal or greater to the number of queues that you pass to the constructor and use many producer threads and you have to initialize first the Push() method with high(pqueue.long), look at how to do it inside the test1.pas example inside the zip file, so that it become scalable.
The following have been added:
- You can give the following priorities to jobs:
LOW_PRIORITY
NORMAL_PRIORITY
HIGH_PRIORITY
- A queue for each worker thread and it uses work-stealing - for more efficiency -
- Enters in a wait state when there is no job in the queue - for more efficiency -
- Uses O(1) complexity on enqueue and O(3) worst case complexity on dequeue.
Look into defines.inc there is many options:
CPU32: for 32 bits architecture
CPU64: for 64 bits architecture
Look test.pas and at test1.pas examples inside the zip file that shows you that my PQueue is scaling.
Required FPC switches: -O3 -Sd -dFPC -dWin32 -dFreePascal
-Sd for delphi mode....
Required Delphi switches: -DMSWINDOWS -$H+
For Delphi 5,6,7 use -DDelphi
For Delphi 2005,2006,2007,2009,2010+ use the switch -DDELPHI2005+
You can download scalable and relaxed MPMC priority Queue to
version 1.02 from:
http://pages.videotron.com/aminer/Thank you,
Amine Moulay Ramdane.