Public Member Functions

MMutexLock Class Reference

This reference page is linked to from the following overview topics: Threading and Maya, API Classes and plug-ins, Threading and Maya API.


Search for all occurrences

Detailed Description

Methods for managing locks on threads created with MThreadPool and MThreadAsync.

Mutex lock class to be used with threads created by MThreadPool and MThreadAsync.

Examples:

cvColorShader.cpp, and threadTestWithLocksCmd.cpp.

#include <MMutexLock.h>

List of all members.

Public Member Functions

 MMutexLock ()
 Create new mutex object.
 ~MMutexLock ()
 Calling the destructor on a locked mutex does not unlock the mutex.
void lock ()
 Create a lock.
void unlock ()
 Release the current lock on a mutex.
bool tryLock ()
 Attempt to lock the mutex.

Constructor & Destructor Documentation

Create new mutex object.

The object is created unlocked.

~MMutexLock ( )

Calling the destructor on a locked mutex does not unlock the mutex.

That must be done by calling unlock() before calling the destructor.


Member Function Documentation

void lock ( )

Create a lock.

If the mutex 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.

bool tryLock ( )

Attempt to lock the mutex.

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

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

MMutexLock MMutexLock MMutexLock MMutexLock MMutexLock MMutexLock MMutexLock MMutexLock MMutexLock MMutexLock
MMutexLock MMutexLock MMutexLock MMutexLock MMutexLock MMutexLock MMutexLock MMutexLock MMutexLock MMutexLock