在不阻止的情况下尝试获取 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 所有权。
返回值
如果此方法成功获取 mutex 的所有权,则为 true;否则为 false。
备注
如果调用线程已拥有 mutex,则该行为不确定。
要求
标头: mutex
命名空间: std