Hello,
I have updated SemaCondvar to version 1.1, now it supports ALL the charateristics of a semaphore and a condition variable,
i have also corrected a bug.
Description: SemaCondvar and SemaMonitor are new and portable synchronization objects that combine all the characteristics of a semaphore and a condition variable, they only use an event object and a critical section, so they are fast.
Now you can pass the SemCondvar's initialcount
and SemCondvar's MaximumCount to the construtor, it's like the Semaphore`s InitialCount and the Semaphore's MaximumCount.
Like this:
t:=TSemaMonitor.create(true,0,4);
When you pass True in the first parameter of the constructor the signal(s) will not be lost even if there is no waiting threads,
if it's False the signal(s) will be lost if there is no waiting thread.
If you want to detect spurious wakeups just test the boolean value returned by the timed wait method.
Here is the methods that i have implemented
TSemaCondvar = class
public
constructor Create(m1:TCriticalSection;state1:boolean=false;InitialCount1:longword=0;MaximumCount1:longword=INFINITE);
destructor Destroy; override;
function wait(mstime:longword=INFINITE):boolean;
procedure signal();overload;
procedure signal_all();
procedure signal(nbr:integer);overload;
function WaitersBlocked:integer;
end;
TSemaMonitor = class
public
constructor Create(state1:boolean=false;InitialCount1:longword=0;MaximumCount1:longword=INFINITE);
destructor Destroy; override;
function wait(mstime:longword=INFINITE):boolean;
procedure signal();overload;
procedure signal_all();
procedure signal(nbr:integer);overload;
function WaitersBlocked:integer;
end;
You can download SemaCondvar 1.1 from:
http://pages.videotron.com/aminer/Thank you,
Amine Moulay Ramdane.