[英]Difference between mutex.timed_lock(duration) and boost::timed_mutex::scoped_lock scoped_lock(mutex, duration)
I would like to know which is the difference between: 我想知道两者之间的区别:
boost::timed_mutex _mutex;
if(_mutex.timed_lock(boost::get_system_time() + boost::posix_time::milliseconds(10))){
exclusive code
_mutex.unlock();
}
and 和
boost::timed_mutex _mutex;
boost::timed_mutex::scoped_lock scoped_lock(_mutex, boost::get_system_time() + boost::posix_time::milliseconds(10));
if(scoped_lock.owns_lock()) {
exclusive code
}
I do know already that the scoped_lock makes unnecessary the call to unlock. 我确实已经知道scoped_lock使得不必要进行解锁调用。 My question refers to:
我的问题是指:
I'll try to answer your questions: 我会尽力回答您的问题:
unique_lock<timed_mutex>
) from posix_time. unique_lock<timed_mutex>
)。 I personally prefer duration.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.