[fpc-pascal] Semaphore
Damien Gerard
milipili at shikami.org
Tue Feb 12 14:21:29 CET 2008
Le Feb 12, 2008 à 12:36 PM, Graeme Geldenhuys a écrit :
> On 11/02/2008, Damien Gerard <milipili at shikami.org> 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;
I realize you have already made a TSemaphore like. May be I can
directly use it for my purposes ?
--
Damien Gerard
milipili at shikami.org
Le temps n'a pas d'importance. Seul le code est important
-- (f00ty)
More information about the fpc-pascal
mailing list