开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜