MDL SDK API nvidia_logo_transpbg.gif Up
Multithreading Support

Primitives useful for multithreaded applications, for example, atomic counters, condition variables, and locks. More...

Classes

class  mi::base::Atom32
 A 32-bit unsigned counter with atomic arithmetic, increments, and decrements. More...
 
class  mi::base::Condition
 Conditions allow threads to signal an event and to wait for such a signal, respectively. More...
 
class  mi::base::Lock
 Non-recursive lock class. More...
 
class  mi::base::Lock::Block
 Utility class to acquire a lock that is released by the destructor. More...
 
class  mi::base::Recursive_lock
 Recursive lock class. More...
 
class  mi::base::Recursive_lock::Block
 Utility class to acquire a lock that is released by the destructor. More...
 

Functions

 mi::base::Atom32::Atom32 ()
 The default constructor initializes the counter to zero. More...
 
 mi::base::Atom32::Atom32 (const Uint32 value)
 This constructor initializes the counter to value. More...
 
 mi::base::Atom32::Atom32 (const Atom32 &other)
 The copy constructor assigns the value of other to the counter. More...
 
Atom32mi::base::Atom32::operator= (const Atom32 &rhs)
 Assigns the value of rhs to the counter. More...
 
Uint32 mi::base::Atom32::operator= (const Uint32 rhs)
 Assigns rhs to the counter. More...
 
Uint32 mi::base::Atom32::operator+= (const Uint32 rhs)
 Adds rhs to the counter. More...
 
Uint32 mi::base::Atom32::operator-= (const Uint32 rhs)
 Subtracts rhs from the counter. More...
 
Uint32 mi::base::Atom32::operator++ ()
 Increments the counter by one (pre-increment). More...
 
Uint32 mi::base::Atom32::operator++ (int)
 Increments the counter by one (post-increment). More...
 
Uint32 mi::base::Atom32::operator-- ()
 Decrements the counter by one (pre-decrement). More...
 
Uint32 mi::base::Atom32::operator-- (int)
 Decrements the counter by one (post-decrement). More...
 
 mi::base::Atom32::operator Uint32 () const
 Conversion operator to mi::Uint32. More...
 
Uint32 mi::base::Atom32::swap (const Uint32 rhs)
 Assigns rhs to the counter and returns the old value of counter. More...
 
 mi::base::Condition::Condition ()
 Constructor. More...
 
 mi::base::Condition::~Condition ()
 Destructor. More...
 
void mi::base::Condition::wait ()
 Waits for the condition to be signaled. More...
 
bool mi::base::Condition::timed_wait (Float64 timeout)
 Waits for the condition to be signaled until a given timeout. More...
 
void mi::base::Condition::signal ()
 Signals the condition. More...
 
void mi::base::Condition::reset ()
 Resets the condition. More...
 
 mi::base::Lock::Lock ()
 Constructor. More...
 
 mi::base::Lock::~Lock ()
 Destructor. More...
 
 mi::base::Lock::Block::Block (Lock *lock=0)
 Constructor. More...
 
 mi::base::Lock::Block::~Block ()
 Destructor. More...
 
void mi::base::Lock::Block::set (Lock *lock)
 Acquires a lock. More...
 
bool mi::base::Lock::Block::try_set (Lock *lock)
 Tries to acquire a lock. More...
 
void mi::base::Lock::Block::release ()
 Releases the lock. More...
 
void mi::base::Lock::lock ()
 Locks the lock. More...
 
bool mi::base::Lock::try_lock ()
 Tries to lock the lock. More...
 
void mi::base::Lock::unlock ()
 Unlocks the lock. More...
 
 mi::base::Recursive_lock::Recursive_lock ()
 Constructor. More...
 
 mi::base::Recursive_lock::~Recursive_lock ()
 Destructor. More...
 
 mi::base::Recursive_lock::Block::Block (Recursive_lock *lock=0)
 Constructor. More...
 
 mi::base::Recursive_lock::Block::~Block ()
 Destructor. More...
 
void mi::base::Recursive_lock::Block::set (Recursive_lock *lock)
 Acquires a lock. More...
 
bool mi::base::Recursive_lock::Block::try_set (Recursive_lock *lock)
 Tries to acquire a lock. More...
 
void mi::base::Recursive_lock::Block::release ()
 Releases the lock. More...
 
void mi::base::Recursive_lock::lock ()
 Locks the lock. More...
 
bool mi::base::Recursive_lock::try_lock ()
 Tries to lock the lock. More...
 
void mi::base::Recursive_lock::unlock ()
 Unlocks the lock. More...
 

Detailed Description

Primitives useful for multithreaded applications, for example, atomic counters, condition variables, and locks.

Function Documentation

 Atom32() [1/3]

mi::base::Atom32::Atom32 ( )
inline

The default constructor initializes the counter to zero.

 Atom32() [2/3]

mi::base::Atom32::Atom32 ( const Atom32 other)

The copy constructor assigns the value of other to the counter.

 Atom32() [3/3]

mi::base::Atom32::Atom32 ( const Uint32  value)
inline

This constructor initializes the counter to value.

 Block() [1/2]

mi::base::Lock::Block::Block ( Lock lock = 0)
explicit

Constructor.

Parameters
lockIf not NULL, this lock is acquired. If NULL, set() can be used to explicitly acquire a lock later.

 Block() [2/2]

mi::base::Recursive_lock::Block::Block ( Recursive_lock lock = 0)
explicit

Constructor.

Parameters
lockIf not NULL, this lock is acquired. If NULL, set() can be used to explicitly acquire a lock later.

 Condition()

mi::base::Condition::Condition ( )
inline

Constructor.

 Lock()

mi::base::Lock::Lock ( )

Constructor.

 lock() [1/2]

void mi::base::Lock::lock ( )
protected

Locks the lock.

 lock() [2/2]

void mi::base::Recursive_lock::lock ( )
protected

Locks the lock.

 operator Uint32()

mi::base::Atom32::operator Uint32 ( ) const
inline

Conversion operator to mi::Uint32.

 operator++() [1/2]

Uint32 mi::base::Atom32::operator++ ( )

Increments the counter by one (pre-increment).

 operator++() [2/2]

Uint32 mi::base::Atom32::operator++ ( int  )

Increments the counter by one (post-increment).

 operator+=()

Uint32 mi::base::Atom32::operator+= ( const Uint32  rhs)

Adds rhs to the counter.

 operator--() [1/2]

Uint32 mi::base::Atom32::operator-- ( )

Decrements the counter by one (pre-decrement).

 operator--() [2/2]

Uint32 mi::base::Atom32::operator-- ( int  )

Decrements the counter by one (post-decrement).

 operator-=()

Uint32 mi::base::Atom32::operator-= ( const Uint32  rhs)

Subtracts rhs from the counter.

 operator=() [1/2]

Atom32 & mi::base::Atom32::operator= ( const Atom32 rhs)

Assigns the value of rhs to the counter.

 operator=() [2/2]

Uint32 mi::base::Atom32::operator= ( const Uint32  rhs)
inline

Assigns rhs to the counter.

 Recursive_lock()

mi::base::Recursive_lock::Recursive_lock ( )

Constructor.

 release() [1/2]

void mi::base::Lock::Block::release ( )

Releases the lock.

Useful to release the lock before the destructor is called.

 release() [2/2]

void mi::base::Recursive_lock::Block::release ( )

Releases the lock.

Useful to release the lock before the destructor is called.

 reset()

void mi::base::Condition::reset ( )
inline

Resets the condition.

This will undo the effect of a signal() call if there was no outstanding wait() call.

 set() [1/2]

void mi::base::Lock::Block::set ( Lock lock)

Acquires a lock.

Releases the current lock (if it is set) and acquires the given lock. Useful to acquire a different lock, or to acquire a lock if no lock was acquired in the constructor.

This method does nothing if the passed lock is already acquired by this class.

Parameters
lockThe new lock to acquire.

 set() [2/2]

void mi::base::Recursive_lock::Block::set ( Recursive_lock lock)

Acquires a lock.

Releases the current lock (if it is set) and acquires the given lock. Useful to acquire a different lock, or to acquire a lock if no lock was acquired in the constructor.

This method does nothing if the passed lock is already acquired by this class.

Parameters
lockThe new lock to acquire.

 signal()

void mi::base::Condition::signal ( )
inline

Signals the condition.

This will wake up one thread waiting for the condition. It does not matter if the call to signal() or wait() comes first.

Note
If there are two or more calls to signal() without a call to wait() in between (and no outstanding wait() call), all calls to signal() except the first one are ignored, i.e., calls to signal() do not increment some counter, but just set a flag.

 swap()

Uint32 mi::base::Atom32::swap ( const Uint32  rhs)

Assigns rhs to the counter and returns the old value of counter.

 timed_wait()

bool mi::base::Condition::timed_wait ( Float64  timeout)
inline

Waits for the condition to be signaled until a given timeout.

If the condition is already signaled at this time the call will return immediately.

Parameters
timeoutMaximum time period (in seconds) to wait for the condition to be signaled.
Returns
true if the timeout was hit, and false if the condition was signaled.

 try_lock() [1/2]

bool mi::base::Lock::try_lock ( )
protected

Tries to lock the lock.

 try_lock() [2/2]

bool mi::base::Recursive_lock::try_lock ( )
protected

Tries to lock the lock.

 try_set() [1/2]

bool mi::base::Lock::Block::try_set ( Lock lock)

Tries to acquire a lock.

Releases the current lock (if it is set) and tries to acquire the given lock. Useful to acquire a different lock without blocking, or to acquire a lock without blocking if no lock was acquired in the constructor.

This method does nothing if the passed lock is already acquired by this class.

Parameters
lockThe new lock to acquire.
Returns
true if the lock was acquired, false otherwise.

 try_set() [2/2]

bool mi::base::Recursive_lock::Block::try_set ( Recursive_lock lock)

Tries to acquire a lock.

Releases the current lock (if it is set) and tries to acquire the given lock. Useful to acquire a different lock without blocking, or to acquire a lock without blocking if no lock was acquired in the constructor.

This method does nothing if the passed lock is already acquired by this class.

Parameters
lockThe new lock to acquire.
Returns
true if the lock was acquired, false otherwise.

 unlock() [1/2]

void mi::base::Lock::unlock ( )
protected

Unlocks the lock.

 unlock() [2/2]

void mi::base::Recursive_lock::unlock ( )
protected

Unlocks the lock.

 wait()

void mi::base::Condition::wait ( )
inline

Waits for the condition to be signaled.

If the condition is already signaled at this time the call will return immediately.

 ~Block() [1/2]

mi::base::Lock::Block::~Block ( )

Destructor.

Releases the lock (if it is acquired).

 ~Block() [2/2]

mi::base::Recursive_lock::Block::~Block ( )

Destructor.

Releases the lock (if it is acquired).

 ~Condition()

mi::base::Condition::~Condition ( )
inline

Destructor.

 ~Lock()

mi::base::Lock::~Lock ( )

Destructor.

 ~Recursive_lock()

mi::base::Recursive_lock::~Recursive_lock ( )

Destructor.