std::recursive_timed_mutex::unlock
来自cppreference.com
< cpp | thread | recursive timed mutex
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| void unlock(); |
(C++11 起) | |
解锁互斥.
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.
目录 |
[编辑] 参数
(无)
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.
[编辑] 返回值
(无)
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.
[编辑] 例外
| 本节是不完整的 |
[编辑] 为例
这个例子显示了锁,函数try_lock和解锁行动
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)
[编辑] 另请参阅
| 锁住互斥体,块,如果该互斥锁不可用 Original: locks the mutex, blocks if the mutex is not available The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 试图锁定互斥锁,则返回,如果该互斥锁不可用 Original: tries to lock the mutex, returns if the mutex is not available The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 试图锁定互斥锁,则返回在指定的超时时间,如果互斥体有been unavailable的 Original: tries to lock the mutex, returns if the mutex has been unavailable for the specified timeout duration The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |
| 试图锁定互斥锁,返回到指定的时间点已经达到,如果互斥been unavailable的 Original: tries to lock the mutex, returns if the mutex has been unavailable until specified time point has been reached The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (公共成员函数) | |