Threading
Mutex class - Threading
Mutex constructor - Threading
// PROTOTYPE
Mutex()
Construct a new Mutex object. You will often include a Mutex
either as a member of your class, or you can make Mutex
a public superclass of your class, which will make the lock, try_lock, and unlock methods automatically available to your class.
Mutex::lock - Threading
// PROTOTYPE
void lock();
Lock the mutex. If the mutex is already locked, blocks the current thread until is is unlocked.
A Mutex
can only be locked once, even from the same thread. If you need to be able to lock a mutex multiple times, you should use RecursiveMutex
instead.
You cannot lock a mutex from an ISR.
Mutex::trylock - Threading
// PROTOTYPE
bool trylock();
bool try_lock();
Attempts to lock the mutex If it is unlocked, it will be locked and true
is returned. If it is already locked, false
is returned and the thread that previously held the lock will continue to hold the lock.
You cannot lock a mutex from an ISR.
Mutex::unlock - Threading
// PROTOTYPE
void unlock();
Unlocks the mutex. Typically only the thread that locked the mutex will unlock it.
You cannot unlock a mutex from an ISR.