std::unique_lock::unique_lock
来自cppreference.com
< cpp | thread | unique lock
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
unique_lock(); |
(1) | (C++11 起) |
unique_lock( unique_lock&& other ); |
(2) | (C++11 起) |
explicit unique_lock( mutex_type& m ); |
(3) | (C++11 起) |
unique_lock( mutex_type& m, std::defer_lock_t t ); |
(4) | (C++11 起) |
unique_lock( mutex_type& m, std::try_to_lock_t t ); |
(5) | (C++11 起) |
unique_lock( mutex_type& m, std::adopt_lock_t t ); |
(6) | (C++11 起) |
template< class Rep, class Period > unique_lock( mutex_type& m, |
(7) | (C++11 起) |
template< class Clock, class Period > unique_lock( mutex_type& m, |
(8) | (C++11 起) |
构造一个
1) unique_lock
,可以提供的互斥锁.原文:
Constructs a
unique_lock
, optionally locking the supplied mutex.构造一个
2) unique_lock
没有相关的互斥量.原文:
Constructs a
unique_lock
with no associated mutex.移动的构造函数。初始化与内容
3-8) unique_lock
other
.原文:
Move constructor. Initializes the
unique_lock
with the contents of other
.构造一个
unique_lock
m
相关联的互斥量。此外原文:
Constructs a
unique_lock
with m
as the associated mutex. Additionally:- 3) 相关的互斥锁通过调用m.lock().原文:Locks the associated mutex by calling m.lock().
- 4) 不锁定相关联的互斥锁.
- 5) 尝试锁定相关联的互斥体而不会阻止通过调用m.try_lock().原文:Tries to lock the associated mutex without blocking by calling m.try_lock().
- 6) 假设调用线程已经拥有
m
.原文:Assumes the calling thread already ownsm
.
- 7) 试图锁定相关联的互斥体。已过或阻塞,直到指定
timeout_duration
获得该锁,以先到者为准。可能会阻止长于timeout_duration
.原文:Tries to lock the associated mutex. Blocks until specifiedtimeout_duration
has elapsed or the lock is acquired, whichever comes first. May block for longer thantimeout_duration
.
- 8) 试图锁定相关联的互斥体。阻塞,直到指定
timeout_time
已达到或获得该锁,以先到者为准。可能会阻止长于timeout_time
已经达到了前.原文:Tries to lock the associated mutex. Blocks until specifiedtimeout_time
has been reached or the lock is acquired, whichever comes first. May block for longer than untiltimeout_time
has been reached.
[编辑] 参数
other | - | 另一个
unique_lock 状态进行初始化原文: another unique_lock to initialize the state with |
m | - | 互斥锁与锁和可选的拥有权
原文: mutex to associate with the lock and optionally acquire ownership of |
t | - | 标签参数,用于选择不同的锁定策略的构造函数
原文: tag parameter used to select constructors with different locking strategies |
timeout_duration | - | 阻塞最长持续时间
|
timeout_time | - | 阻塞,直到最大的时间点
|
[编辑] 例外
1, 2, 4)[编辑] 示例
本章尚未完成 原因:暂无示例 |