不阻止,尝试获取 mutex 的所有权。
template<class Clock, class Duration>
bool try_lock_for(const chrono::time_point<Clock, Duration>& Abs_time);
bool try_lock_until(const xtime *Abs_time);
参数
- Abs_time
指定的阈值,在之后方法的时间点不再尝试获取 mutex的所有权。
返回值
true,如果方法成功获取 mutex 的所有权,或者调用线程已拥有 mutex;否则,false。
备注
如果调用线程已拥有 mutex,则此方法会立即返回 true,并且,以前锁定仍然有效。
要求
**标头:**mutex
**命名空间:**std