在线文档教程
C++
线程支持 | Thread support

std::shared_lock::try_lock_until

STD::共享[医]锁::试一试[医]锁[医]直到

template< class Clock, class Duration > bool try_lock_until( const std::chrono::time_point& timeout_time (since C++14)

尝试将关联的互斥锁在共享模式下。块,直到指定timeout_time已到达或已获得锁,两者以第一位为准。关于成功锁定获取返回true,否则返回false.可能会阻塞更长的时间直到timeout_time已经联系到了。

有效呼叫mutex()->try_lock_shared_until(timeout_time)...

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

参数

timeout_time-maximum time point to block until

返回值

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

例外

  • 引发的任何异常mutex()->try_lock_shared_for(timeout_time)

  • 如果没有关联的互斥,std::system_error错误代码为std::errc::operation_not_permitted

  • 如果互斥锁已经锁定,std::system_error错误代码为std::errc::resource_deadlock_would_occur

另见

locklocks the associated mutex (public member function)
try_locktries to lock the associated mutex (public member function)
try_lock_fortries to lock the associated mutex, for the specified duration (public member function)
unlockunlocks the associated mutex (public member function)
try_lock_untiltries to lock the associated TimedLockable mutex, returns if the mutex has been unavailable until specified time point has been reached (public member function of std::unique_lock)

© cppreference.com

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

http://en.cppreference.com/w/cpp/线程/Shared[医]锁/试[医]锁[医]直到