TROSemaphore

Overview

The TROSemaphore class is the cross-platform synchronization object that is a mutex under the hood.
This object is used internally by the TROThreadPool class and is available to users requiring a cross-platform synchronization object. All differences between various platforms and compilers are handled internally inside this class.

Location

Instance Methods


constructor Create

Creates a new instance.

constructor Create

CloseHandle

Destroys the underlying synchronization object. This method is called by the destructor and there is no need to call it explicitly. Once destroyed, the underlying synchronization object cannot be recreated.

procedure CloseHandle

Release  overload

Decreases the semaphore counter by 1. For Windows it is a ReleaseSemaphore call.

procedure Release

Release (Integer)  overload

Decreases the semaphore counter by the specified number. Calls the method above for the required number of times.

procedure Release(Count: Integer)

Parameters:

  • Count: Number to decrease the semaphore counter by.

WaitFor

Waits until the semaphore is in the signaled state (counter is greater than zero) or the time-out interval elapses. For Windows it is equivalent to the WaitForSingleObject call.

function WaitFor(aTimeout: Cardinal): Boolean

Parameters:

  • aTimeout: Time to wait in milliseconds.