std::recursive_timed_mutex::unlock
From cppreference.com
< cpp | thread | recursive timed mutex
void unlock(); |
(since C++11) | |
Unlocks the mutex.
Contents |
[edit] Parameters
(none)
[edit] Return value
(none)
[edit] Exceptions
This section is incomplete |
[edit] Example
This example shows lock, try_lock and unlock in action
#include <iostream> #include <mutex> int main() { std::mutex test; if (test.try_lock()==true) std::cout << "lock acquired" << std::endl; else std::cout << "lock not acquired" << std::endl; test.unlock(); //now unlock the mutex test.lock(); //to lock it again if (test.try_lock()) //true can be left out std::cout << "lock acquired" << std::endl; else std::cout << "lock not acquired" << std::endl; test.lock(); //and now the finale (a block) }
Output:
lock acquired lock not acquired (program hangs)
[edit] See also
locks the mutex, blocks if the mutex is not available (public member function) | |
tries to lock the mutex, returns if the mutex is not available (public member function) | |
tries to lock the mutex, returns if the mutex has been unavailable for the specified timeout duration (public member function) | |
tries to lock the mutex, returns if the mutex has been unavailable until specified time point has been reached (public member function) |