std::unique_lock::try_lock
来自cppreference.com
< cpp | thread | unique lock
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
bool try_lock(); |
(C++11 起) | |
不阻塞的情况下试图锁定相关联的互斥体。有效地调用mutex()->try_lock().
原文:
Tries to lock the associated mutex without blocking. Effectively calls mutex()->try_lock().
std::system_error被抛出,如果没有相关的互斥或如果该互斥锁已经锁定.
原文:
std::system_error is thrown if there is no associated mutex or if the mutex is already locked.
目录 |
[编辑] 参数
(无)
[编辑] 返回值
true如果已成功获取互斥体的所有权,false否则.
原文:
true if the ownership of the mutex has been acquired successfully, false otherwise.
[编辑] 例外
- mutex()->try_lock()抛出的任何异常原文:Any exceptions thrown by mutex()->try_lock()
- 如果没有相关的互斥体,std::system_error的错误代码std::errc::operation_not_permitted原文:If there is no associated mutex, std::system_error with an error code of std::errc::operation_not_permitted
- 如果互斥锁已被锁定,std::system_error的std::errc::resource_deadlock_would_occur的错误代码原文:If the mutex is already locked, std::system_error with an error code of std::errc::resource_deadlock_would_occur
[编辑] 示例
本章尚未完成 原因:暂无示例 |
[编辑] 另请参阅
locks the associated mutex (公共成员函数) | |
来锁定相关的 TimedLockable 互斥体,互斥体的回报,如果一直无法在指定的时间持续时间原文: attempts to lock the associated TimedLockable mutex, returns if the mutex has been unavailable for the specified time duration(公共成员函数) | |
试图锁定相关的 TimedLockable 互斥的回报,如果互斥体已经不可用,直到指定的时间点已经达到 原文: tries to lock the associated TimedLockable mutex, returns if the mutex has been unavailable until specified time point has been reached (公共成员函数) | |
解锁相关的互斥 (公共成员函数) |