std::mutex And Friends#
std::mutex#
Simplest mutual exclusion device
Can be taken only once
Not recursive ⟶ self-deadlock when same thread tries to lock twice
Operation |
Description |
|---|---|
Constructor |
|
|
Locks, potentially suspending caller if locked by somebody else |
|
Unlocks |
|
Does not block; returns Use is questionable though! |
std::recursive_mutex#
Same thread may lock one mutex multiple times
Must unlock as many times!
Operation |
Description |
|---|---|
Constructor |
|
|
Locks, potentially suspending caller if locked by somebody else |
|
Unlocks |
|
Does not block; returns Use is questionable though! |
std::timed_mutex#
Like
std::mutex, only withtry_lock()timeouts
Operation |
Description |
|---|---|
|
Blocks if unavailable, and returns |
|
Timeout occurs at an absolute |
std::recursive_timed_mutex#
…