std::unique_lock::try_lock_until
来自cppreference.com
< cpp | thread | unique lock
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
template< class Clock, class Duration > bool try_lock_until( const std::chrono::time_point<Clock,Duration>& timeout_time ); |
(C++11 起) | |
试图锁定相关联的互斥体。阻塞,直到指定
timeout_time
已达到或获得该锁,以先到者为准。在成功锁定获取回报true,否则返回false。可能会阻止长于timeout_time
已经达到了前.原文:
Tries to lock the associated mutex. Blocks until specified
timeout_time
has been reached or the lock is acquired, whichever comes first. On successful lock acquisition returns true, otherwise returns false. May block for longer than until timeout_time
has been reached.有效地调用mutex()->try_lock_until(timeout_time)
原文:
Effectively calls mutex()->try_lock_until(timeout_time)
std::system_error被抛出,如果没有相关的互斥或如果该互斥锁已经锁定.
原文:
std::system_error is thrown if there is no associated mutex or if the mutex is already locked.
目录 |
[编辑] 参数
timeout_time | - | 阻塞,直到最大的时间点
|
[编辑] 返回值
true如果已成功获取互斥体的所有权,false否则.
原文:
true if the ownership of the mutex has been acquired successfully, false otherwise.
[编辑] 例外
- mutex()->try_lock_for(timeout_time)抛出的任何异常原文:Any exceptions thrown by mutex()->try_lock_for(timeout_time)
- 如果没有相关的互斥体,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 (公共成员函数) | |
试图锁定相关联的互斥量,退货,如果该互斥锁不可用 原文: tries to lock the associated mutex, returns if the mutex is not available (公共成员函数) | |
来锁定相关的 TimedLockable 互斥体,互斥体的回报,如果一直无法在指定的时间持续时间原文: attempts to lock the associated TimedLockable mutex, returns if the mutex has been unavailable for the specified time duration(公共成员函数) | |
解锁相关的互斥 (公共成员函数) |