Le Feb 12, 2008 à 12:36 PM, Graeme Geldenhuys a écrit :

On 11/02/2008, Damien Gerard <[EMAIL PROTECTED]> wrote:
My program must work under OSX/Nux and Windows.
I may have missed something but I can not find something suitable for
me.
Under Windows OpenSemaphore, under unixes CurrentTM.Semaphore*...

Is there any TSemaphore class of equivalent ? Or may be an example how
to use Semaphores ? :)

I've wondered the same thing.... In the end I had to write code like
the following:
Not idea, but it works. We needed to support Linux and Windows only.


procedure TtiPool.CreatePoolSemaphore;
begin
 {$IFDEF MSWINDOWS}
 if FSemaphore <> 0 then
   CloseHandle(FSemaphore);
 FSemaphore := CreateSemaphore(nil, FMaxPoolSize, FMaxPoolSize, nil);
 {$ENDIF MSWINDOWS}
 {$IFDEF LINUX}
 sem_destroy(FSemaphore);
 if sem_init(FSemaphore, 0, FMaxPoolSize) <> 0 then
   raise Exception.Create('Failed to create the semaphore');
 {$ENDIF LINUX}
end;


Thanks !

I think I can safely change LINUX by UNIX and it should work on OS X too.
I will made a TSemaphore :)



Regards,
 - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



--
Damien Gerard
[EMAIL PROTECTED]

Le temps n'a pas d'importance. Seul le code est important
   -- (f00ty)




_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to