NVIDIA Iray: Math API nvidia_logo_transpbg.gif Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
mi::base::Recursive_lock::Block Class Reference

Utility class to acquire a lock that is released by the destructor. More...

Public Member Functions

 Block (Recursive_lock *lock=0)
 Constructor. More...
 
 ~Block ()
 Destructor. More...
 
void set (Recursive_lock *lock)
 Acquires a lock. More...
 
bool try_set (Recursive_lock *lock)
 Tries to acquire a lock. More...
 
void release ()
 Releases the lock. More...
 

Detailed Description

Utility class to acquire a lock that is released by the destructor.

See Also
mi::base::Recursive_lock

Constructor & Destructor Documentation

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.
mi::base::Recursive_lock::Block::~Block ( )

Destructor.

Releases the lock (if it is acquired).

Member Function Documentation

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

Releases the lock.

Useful to release the lock before the destructor is called.

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.
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.