Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #2594 > unrolled thread

About my SemaCondvar and SemaMonitor...

Started byRamine <ramine@1.1>
First post2014-09-15 13:37 -0700
Last post2014-09-15 13:37 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.programming.threads


Contents

  About my SemaCondvar and SemaMonitor... Ramine <ramine@1.1> - 2014-09-15 13:37 -0700

#2594 — About my SemaCondvar and SemaMonitor...

FromRamine <ramine@1.1>
Date2014-09-15 13:37 -0700
SubjectAbout my SemaCondvar and SemaMonitor...
Message-ID<lv7833$7r3$1@dont-email.me>
Hello,


I want to clear something about my new inventions and algorithms
that are my SemaCondVar and my SemaMonitor, if you want the faster 
SemaCondVar and SemaMonitor use the ones inside my zipfile of my 
concurrent FIFO queue 1 here:

https://sites.google.com/site/aminer68/concurrent-fifo-queue-1


The others that you find here are heavy weight:


https://sites.google.com/site/aminer68/semacondvar-semamonitor


SemaCondvar and SemaMonitor are new and portable synchronization objects 
, SemaCondvar combines all the charateristics of a semaphore and a 
condition variable and SemaMonitor combines all charateristics of a 
semaphore and an eventcount , they only use an event object and and a 
very fast and very efficient and portable FIFO fair Lock , so they are 
fast and they are FIFO fair.

Now you can pass the SemaCondvar's initialcount  and SemaCondvar'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.

As you will notice i have used a scalable and efficient and FIFO fair 
Lock inside SemaCondVar.pas, i have made ,  but you will notice that 
this Lock is now portable to the x86 systems and to Linux(x86) , Mac 
OSX(x86) and Windows(x86), but if you want to port it to other systems 
than the x86, please change inside SemaCondVar.pas the TALOCK by the 
TCriticalSection of the SyncObjs unit and it will be portable to other 
systems than the x86. That's all. So enjoy SemaCondvar and SemaMonitor.

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;
      procedure setSignal;
      procedure  resetSignal;
    end;





Thank you,
Amine Moulay Ramdane.


[toc] | [standalone]


Back to top | Article view | comp.programming.threads


csiph-web