首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::shared_timed_mutex::try_lock_shared_for

template< class Rep, class Period > bool try_lock_shared_for( const std::chrono::duration<Rep,Period>& timeout_duration );

?

(since C++14)

尝试将互斥锁在共享模式下。块,直到指定timeout_duration已过或已获得共享锁,两者以第一位为准。关于成功锁定获取返回true,否则返回false...

如果timeout_duration小于或等于timeout_duration.zero(),该函数的行为类似于try_lock_shared()...

用一个稳定的时钟来测量持续时间。此函数的阻塞时间可能超过timeout_duration由于调度或资源争用延迟。

和...一样try_lock_shared(),则允许此函数伪造失败并返回。false期间,即使互斥锁没有被任何其他线程锁定。timeout_duration...

优先unlock()对同一个互斥体的操作同步性中定义的28名ASstd::memory_order%29如果返回此操作true...

如果try_lock_shared_for由已经拥有mutex在任何模式%28共享或独占%29中,行为都是未定义的。

参数

timeout_duration

-

maximum duration to block for

返回值

true如果成功获取锁,则为false...

例外

任何由时钟、时间引发的异常[医]在执行%28时钟、时间点和标准库提供的持续时间期间,不要抛出%29。

另见

try_lock_shared

tries to lock the mutex for shared ownership, returns if the mutex is not available (public member function)

try_lock_shared_until

tries to lock the mutex for shared ownership, returns if the mutex has beenunavailable until specified time point has been reached (public member function)

try_lock_for

tries to lock the mutex, returns if the mutex has beenunavailable for the specified timeout duration (public member function)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com