std::recursive_mutex::unlock
Aus cppreference.com
<metanoindex/>
<tbody> </tbody> void unlock(); |
(seit C++11) | |
Das Mutex wieder aufgehoben .
Original:
Unlocks the mutex.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Parameter
(None)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Rückgabewert
(None)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Ausnahmen
| This section is incomplete |
Beispiel
Dieses Beispiel zeigt, Schloss, try_lock und entsperren in Aktion
Original:
This example shows lock, try_lock and unlock in action
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
#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)
