nn::os::Semaphore Class

Header file: nn/os.h

Syntax

class Semaphore : public nn::os::InterruptEvent

Description

Class for handling semaphores. Semaphores are synchronization object that have counters.

Generally, use the nn::os::LightSemaphore class instead of nn::os::Semaphore. The nn::os::LightSemaphore class is better than the nn::os::Semaphore class in most respects, except that it cannot wait for multiple synchronization objects.

The semaphore Wait operation first waits for the semaphore counter to become greater than zero, then increments the semaphore counter by one. Wait operations are not released while the semaphore counter is zero.

Call Release in order to increment a semaphore's counter.

See the reference for the nn::os::Event class for more information about synchronization objects.

Member Functions

Semaphore Constructs and initializes a semaphore.
Initialize Initializes a semaphore that has already been constructed.
TryInitialize Tries to initialize a semaphore that has already been constructed.
Finalize Destroys a semaphore.
~Semaphore Destructor.
Release Releases a semaphore (performs a "V operation") and increases the counter value.
Acquire Acquires a semaphore (performs a "P operation") and decrements the counter value.
TryAcquire Tries to acquire a semaphore (perform a "P operation").

Class Hierarchy

ADLFireWall::NonCopyable
  nn::os::HandleObject
    nn::os::WaitObject
      nn::os::InterruptEvent
        nn::os::Semaphore

Revision History

2010/01/07
Initial version.

CONFIDENTIAL