C++ API Reference

Methods for managing spin locks on threads. More...

#include <MSpinLock.h>

Public Member Functions

 MSpinLock ()
 Create new spin lock object. More...
 
 ~MSpinLock ()
 Destructor. More...
 
void lock ()
 Create a lock. More...
 
void unlock ()
 Release the current lock.
 
bool tryLock ()
 Attempt to lock the object. More...
 

Detailed Description

Methods for managing spin locks on threads.

Lightweight spin-lock class to be used with threads.

Examples:
autoLoader/threadData.cpp, autoLoader/threadData.h, threadingLockTests/threadingLockTests.cpp, and threadTestWithLocksCmd/threadTestWithLocksCmd.cpp.

Constructor & Destructor Documentation

OPENMAYA_MAJOR_NAMESPACE_OPEN MSpinLock ( )

Create new spin lock object.

The object is created unlocked.

~MSpinLock ( )

Destructor.

Calling the desctructor on a locked spin lock object does not unlock the object. That must be done by calling unlock() before calling the destructor.

Member Function Documentation

void lock ( )

Create a lock.

If the object is available it is locked immediately. If it is already locked by another thread, this function waits until the other thread has unlocked it, then creates the lock.

Examples:
autoLoader/threadData.cpp, threadingLockTests/threadingLockTests.cpp, and threadTestWithLocksCmd/threadTestWithLocksCmd.cpp.
bool tryLock ( )

Attempt to lock the object.

If the object is already locked by another thread, the function returns right away.

Returns
  • true lock was obtained
  • false lock was not obtained

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