[Lazarus] Using semaphores to limit thread access

kapibara kapibara.pas at aol.com
Sun Jul 19 18:32:38 CEST 2015


|Hi guys

A number of threads need to access an object, but no more than three threads must access simultaneously.

Thats a job for a semaphore someone said.|||I understand|that under Delphi and Windows something like this could be used:

FSemaphoreHandle:=  CreateSemaphore(nil,  3,  3,  nil);
||WaitForSingleObject(FSemaphoreHandle,  <timeout>);|

How to do that under Lazarus and Linux?

I have found TThreadManager with its SemaphoreInit and SemaphoreWait etc. But how to use it, especially how do you specify the number of threads that can access the object?

Using 32 bit Lazarus trunk and FPC trunk.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20150719/966fd8f3/attachment-0002.html>


More information about the Lazarus mailing list