ADTF  v2.14.3
cSemaphore Class Reference

Semaphore class. More...

Inheritance diagram for cSemaphore:

Public Member Functions

 cSemaphore ()
 Default constructor.
 
virtual ~cSemaphore ()
 Destructor.
 
tResult Create (tInt nMaxCount, tInt nInitialCount=0)
 Creates the semaphore. More...
 
tResult Wait (tInt nTimeout=WAIT_Infinite)
 Blocks the calling thread until the semaphore value is greater than 0. More...
 
tInt Release (tInt nCount=1)
 Increments the semaphore. More...
 

Additional Inherited Members

- Static Public Attributes inherited from IWaitableObject
static const tInt WAIT_Infinite = -1
 value for infinite wait time
 

Detailed Description

Semaphore class.

Definition at line 254 of file thread.h.

Member Function Documentation

tResult Create ( tInt  nMaxCount,
tInt  nInitialCount = 0 
)

Creates the semaphore.

Parameters
nMaxCount[in] Maximum number value of the semaphore.
nInitialCount[in] The initial count of the semaphore.
Return values
ERR_FAILEDif initialisation failed. [Windows]
ERR_NOERRORif all went well; Always returned under linux.
tInt Release ( tInt  nCount = 1)

Increments the semaphore.

Parameters
nCount[in] By how much the semaphore should be increased.
Returns
The old semaphore value if successfull.
Return values
-1if semaphore has been initialized but nCount is bigger than the maximum count specified at initialisation
ERR_NOT_INITIALISED( currently -37 but that may change )
This method is real-time safe.
See The ADTF Real-Time Extension.
tResult Wait ( tInt  nTimeout = WAIT_Infinite)
virtual

Blocks the calling thread until the semaphore value is greater than 0.

Parameters
nTimeout[in] The maximum time to wait.
Return values
ERR_NOERRORif all went well.
ERR_NOT_INITIALISEDif semaphore has not yet been initialised [Windows]
ERR_TIMEOUTin case of timeout. [Windows/Linux]
ERR_FAILEDin case something went wrong [Linux]
ERR_INVALID_ARGif semaphore was abandoned by owning thread[Windows]
This method is real-time safe.
See The ADTF Real-Time Extension.

Implements IWaitableObject.


Copyright © Audi Electronics Venture GmbH. All rights reserved. (Generated on Fri Mar 22 2019 by doxygen 1.8.10)