Jeremy
Jeremy

Reputation: 4975

C++ Boost::thread upgradable mutex "try upgrade lock"?

I implemented boost upgradable mutexes following the top answer here Example of how to use boost upgradeable mutexes

What I would like to do is to "try" whether or not the upgrade will block: if the upgrade will not block performs the upgrade, otherwise don't lock it and returns.

Is there any function to do so?

Upvotes: 0

Views: 495

Answers (1)

geekpp
geekpp

Reputation: 511

Yes there is :
-bool try_lock_upgrade_for(duration d)
-bool try_lock_upgrade_until(time when)

see http://www.boost.org/doc/libs/1_52_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_types.upgrade_mutex

Upvotes: 1

Related Questions