Hello,
Threadpool with priorities version 1.5 (stable version) has been ported to Delphi XE-XE4, i have included the 32 bit and 64 bit memory managers , that scale on multicores , inside the zip file.
Author: Amine Moulay Ramdane
Language: FPC Pascal v2.2.0+ / Delphi 5+:
http://www.freepascal.org/Operating Systems: Win , Linux and Mac (x86).
Description:
Thread Pool Engine.
The following have been added:
- You can give the following priorities to jobs:
LOW_PRIORITY
NORMAL_PRIORITY
HIGH_PRIORITY
- A lock-free 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 -
- You can distribute your jobs to the workers threads and call any method with the threadpool's execute() method.
- 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
Please read an article that i wrote about my Threadpool engine: article.
Look at test1.pas example inside the zip file, to show you how to use PThreadpool engine as a scalable priority MPMC FIFO queue, with this same method you can implement a scalable priority MPMC FIFO queue (note: the exec() method is scalable, but execute() method is not scalable as the exec() method).
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+
Please look at the examples test.pas,testpool.pas and test_thread.pas...
Note: testpool.pas is a parallel program of a Matrix multiply by a vector that uses SSE+ and it requires Delphi 5+. test.pas and test_thread.pas works with both FreePascal and Delphi.
You can dowload Threadpool 1.5 from:
http://pages.videotron.com/aminer/Thank you,
Amine Moulay Ramdane.