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

std::shared_lock::try_lock

bool try_lock();

?

(since C++14)

尝试在不阻塞的情况下将相关互斥锁在共享模式下。有效呼叫mutex()->try_lock_shared()...

std::system_error如果没有关联的互斥对象,或者互斥对象已经锁定,则引发。

参数

%280%29

返回值

true如果互斥体的所有权已经成功获得,false否则。

例外

  • 引发的任何异常mutex()->try_lock_shared()
  • 如果没有关联的互斥,std::system_error错误代码为std::errc::operation_not_permitted
  • 如果互斥锁已经锁定,std::system_error错误代码为std::errc::resource_deadlock_would_occur

另见

try_lock

tries to lock the associated mutex (public member function)

lock

locks the associated mutex (public member function)

try_lock_for

tries to lock the associated mutex, for the specified duration (public member function)

try_lock_until

tries to lock the associated mutex, until a specified time point (public member function)

unlock

unlocks the associated mutex (public member function)

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

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

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com