NvMutex Class Reference

Abstract class that represents a mutex instance. More...

#include <NvThread.h>

List of all members.

Public Member Functions

 NvMutex (void)
 Default constructor Do NOT use.
 NvMutex (const NvMutex &obj)
 Copy constructor Do NOT use.
 NvMutex (const bool recursive, const int lockLevel)
 Constructor Only constructor that creates an instance of a mutex.
virtual ~NvMutex (void)
 Destructor.
Mutex API pure virtual methods
To be overridden with platform specific calls by the implementing derived classes.

virtual void lockMutex (void)=0
 Lock the mutex.
virtual bool tryLockMutex (void)=0
 Lock the mutex.
virtual void unlockMutex (void)=0
 Unlock the mutex If the mutex is recursive, and the currently executing thread had acquired ownership of the mutex, then the lock level is decreased by 1.
virtual bool isMutexLockedByCurrentThread (void)=0
 Check if the mutex is owned by the current thread.

Static Public Attributes

Mutex API constants
These should match the corresponding constants defined in the nn::os namespace.

static const int MutexLockLevelMin = 1
 Minimum level of recursive ownership of a thread allowed for a mutex.
static const int MutexLockLevelMax = 31
 Maximum level of recursive ownership of a thread allowed for a mutex.
static const int MutexLockLevelInitial = 0
 Default level of recursive ownership of a thread allowed for a mutex.
static const int MutexRecursiveLockCountMax = 65535
 Maximum level of recursion allowed for a mutex.


Detailed Description

Abstract class that represents a mutex instance.

Designed to be a wrapper with an almost direct mapping between the mutex-related APIs in the nn::os namespace. It should be derived and implemented according to platform specifications.


Constructor & Destructor Documentation

NvMutex::NvMutex ( void   )  [inline]

Default constructor Do NOT use.

Overwritten for safety; it should trigger an assert or exception.

NvMutex::NvMutex ( const NvMutex obj  )  [inline]

Copy constructor Do NOT use.

Overwritten for safety; it should trigger an assert or exception.

Parameters:
[in] obj reference to instance in attempted copy.

NvMutex::NvMutex ( const bool  recursive,
const int  lockLevel 
) [inline]

Constructor Only constructor that creates an instance of a mutex.

Parameters:
[in] recursive flag that determines if the mutex is recursive (it allows the same thread to acquire multiple levels of ownership over the same mutex)
[in] lockLevel maximum number of ownership levels allowed for the mutex and the same thread


Member Function Documentation

virtual bool NvMutex::isMutexLockedByCurrentThread ( void   )  [pure virtual]

Check if the mutex is owned by the current thread.

This function is provided mostly for use in error-checking code.

Returns:
whether the mutex is owned by the current thread.

virtual void NvMutex::lockMutex ( void   )  [pure virtual]

Lock the mutex.

The currently executing thread acquires ownership of the mutex. This is a BLOCKING call (thread execution is stopped until the thread acquires the mutex, and the method will not return until this is the case).

virtual bool NvMutex::tryLockMutex ( void   )  [pure virtual]

Lock the mutex.

The currently executing thread acquires ownership of the mutex. This is a NON-BLOCKING call (thread execution is NOT stopped until the thread acquires the mutex, and the method will return after the attempt).

Returns:
whether the thread acquired the mutex or not.

virtual void NvMutex::unlockMutex ( void   )  [pure virtual]

Unlock the mutex If the mutex is recursive, and the currently executing thread had acquired ownership of the mutex, then the lock level is decreased by 1.

If the lock level is 0 or if the mutex is non-recursive, and the currently executing thread had acquired ownership of the mutex, then the mutex is unlocked and available to other threads.


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