PixelLightAPI  .
Public Member Functions
PLCore::Semaphore Class Reference

Counting semaphore class. More...

#include <Semaphore.h>

List of all members.

Public Member Functions

PLCORE_API Semaphore (uint32 nValue, uint32 nMaxValue)
 Constructor.
PLCORE_API ~Semaphore ()
 Destructor.
bool Lock ()
 Locks the semaphore.
bool TryLock (uint64 nTimeout)
 Locks the semaphore, but only wait until timeout.
bool Unlock ()
 Unlocks the semaphore.
uint32 GetValue () const
 Gets the current value of the semaphore.

Detailed Description

Counting semaphore class.

Note:
  • Implementation of the bridge design pattern, this class is the abstraction

Constructor & Destructor Documentation

PLCORE_API PLCore::Semaphore::Semaphore ( uint32  nValue,
uint32  nMaxValue 
)

Constructor.

Parameters:
[in]nValueInitial value of the semaphore (usually >0)
[in]nMaxValueMaximum value of the semaphore

Destructor.


Member Function Documentation

bool PLCore::Semaphore::Lock ( ) [inline]

Locks the semaphore.

Returns:
'true' if successful, 'false' on error
Note:
  • Other known names for this operation: p, wait, acquire, down
  • Blocking if no 'signal' left
  • Use the lock method with a timeout to avoid potential deadlocks
bool PLCore::Semaphore::TryLock ( uint64  nTimeout) [inline]

Locks the semaphore, but only wait until timeout.

Parameters:
[in]nTimeoutTimeout in milliseconds
Returns:
'true' if successful, 'false' on error
Note:
  • 'nTimeout = 0' means: Return immediately if no 'signal' left
See also:
bool PLCore::Semaphore::Unlock ( ) [inline]

Unlocks the semaphore.

Returns:
'true' if successful, 'false' on error
Note:
  • Other known names for this operation: v, signal, release, up
uint32 PLCore::Semaphore::GetValue ( ) const [inline]

Gets the current value of the semaphore.

Returns:
Current semaphore value (number of 'signals' left)

The documentation for this class was generated from the following files:


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:16
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported