开发者

create a boost::posix_time::ptime instance for X number of milliseconds

开发者 https://www.devze.com 2023-02-20 20:23 出处:网络
boost::interprocess::scoped_lock<boost::interprocess::named_recursive_mutex> when creating an instance, i need to use the
boost::interprocess::scoped_lock<boost::interprocess::named_recursive_mutex>

when creating an instance, i need to use the

scoped_lock(开发者_开发知识库mutex_type & m, const boost::posix_time::ptime & abs_time);

constructor. how can i create a scoped_lock for X number of miliseconds ?


If X is milliseconds you want to spend while waiting for lock acquirance then this snippet should help you:

boost::posix_time::ptime till = boost::posix_time::microsec_clock::local_time() + 
    boost::posix_time::milliseconds(X);
...
{
    boost::interprocess::scoped_lock(some_mutex, till);
    ...
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号