Oded
Oded

Reputation: 664

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 ?

Upvotes: 0

Views: 954

Answers (1)

Keynslug
Keynslug

Reputation: 2766

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);
    ...
}

Upvotes: 6

Related Questions