0

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?

Community
  • 1
  • 1
Jeremy
  • 4,797
  • 1
  • 18
  • 26
  • Are you asking about Boost itself? That already has [`try_lock_upgrade()`](http://www.boost.org/doc/libs/1_52_0/doc/html/thread/synchronization.html#thread.synchronization.mutex_concepts.upgrade_lockable)... – Kerrek SB Jan 18 '13 at 09:30

1 Answers1

1

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

geekpp
  • 511
  • 2
  • 6
  • Thanks but I am using an ancient version of Boost on default Ubuntu repository. I guess it's not available. http://www.boost.org/doc/libs/1_48_0/doc/html/thread/synchronization.html – Jeremy Jan 18 '13 at 09:50