Boost logo

Boost :

From: dherring_at_[hidden]
Date: 2007-05-23 13:15:18


Hi,

I think there's a minor mistake in the template code for
interprocess_condition::wait.

***** Begin example *****
using namespace boost::interprocess;

#ifdef USE_RECURSIVE
   typedef interprocess_recursive_mutex MutexT;
#else
   typedef interprocess_mutex MutexT;
#endif

MutexT mutex;
scoped_lock<MutexT> lock(mutex);
interprocess_condition condition;
condition.wait(lock); // compilation error when USE_RECURSIVE is defined
***** End example *****

Here, wait() is templated on the lock type; but this calls do_wait(),
which requires interprocess_mutex. Is there a reason why do_wait() cannot
accept a recursive mutex?

The attached diff contains one possible solution:
- Template do_wait() on the mutex type.
- Add "friend class interprocess_condition" to the recursive mutex (as it
   is in the nonrecursive mutex).

This seems to work on my computer (with POSIX_SHARED_MEMORY_OBJECTS); it
has't been tested with the POSIX emulation.

Thanks,
Daniel



Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk