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);
...
}
精彩评论