[interprocess] named_condition compile failure...

I have either not understood the documentation, or found a bug in Boost.Interprocess's named_condition class. If I'm in error, I hope someone can help me. Otherwise, I will need to approach my needs another way. I assume that named_condition requires a named_mutex, as the documentation states in the Description here: http://www.boost.org/doc/libs/1_50_0/doc/html/boost/interprocess/named_condi... "This condition variable is designed to work with named_mutex<http://www.boost.org/doc/libs/1_50_0/doc/html/boost/interprocess/named_mutex.html> and can't be placed in shared memory or memory mapped files." Unfortunately, at least on a VC++ 2010 compiler, this doesn't seem to compile for me. I am using the following test code: #include "stdafx.h" #include <boost/interprocess/sync/named_condition.hpp> #include <boost/interprocess/sync/named_mutex.hpp> int _tmain(int argc, _TCHAR* argv[]) { boost::interprocess::named_mutex mutex( boost::interprocess::open_or_create, "test" ); boost::interprocess::named_condition condition( boost::interprocess::open_or_create, "test" ); condition.wait( mutex ); return 0; } With this code, I get the following error: 1>c:\code\sdks\boost\include\boost-1_50\boost\interprocess\sync\shm\named_condition.hpp(204): error C2248: 'boost::interprocess::interprocess_mutex::mutex' : cannot access private member declared in class 'boost::interprocess::interprocess_mutex' 1> c:\code\sdks\boost\include\boost-1_50\boost\interprocess\sync\interprocess_mutex.hpp(117) : see declaration of 'boost::interprocess::interprocess_mutex::mutex' 1> c:\code\sdks\boost\include\boost-1_50\boost\interprocess\sync\interprocess_mutex.hpp(67) : see declaration of 'boost::interprocess::interprocess_mutex' 1> c:\code\sdks\boost\include\boost-1_50\boost\interprocess\sync\shm\named_condition.hpp(204) : while compiling class template member function 'boost::interprocess::ipcdetail::shm_named_condition::lock_wrapper<Lock>::mutex_type *boost::interprocess::ipcdetail::shm_named_condition::lock_wrapper<Lock>::mutex(void) const' 1> with 1> [ 1> Lock=boost::interprocess::named_mutex 1> ] 1> c:\code\sdks\boost\include\boost-1_50\boost\interprocess\sync\shm\named_condition.hpp(342) : see reference to class template instantiation 'boost::interprocess::ipcdetail::shm_named_condition::lock_wrapper<Lock>' being compiled 1> with 1> [ 1> Lock=boost::interprocess::named_mutex 1> ] 1> c:\code\sdks\boost\include\boost-1_50\boost\interprocess\sync\named_condition.hpp(156) : see reference to function template instantiation 'void boost::interprocess::ipcdetail::shm_named_condition::wait<L>(L &)' being compiled 1> with 1> [ 1> L=boost::interprocess::named_mutex 1> ] 1> c:\code\projects\testinterprocess\testinterprocess\testinterprocess.cpp(10) : see reference to function template instantiation 'void boost::interprocess::named_condition::wait<boost::interprocess::named_mutex>(L &)' being compiled 1> with 1> [ 1> L=boost::interprocess::named_mutex 1> ] 1>c:\code\sdks\boost\include\boost-1_50\boost\interprocess\sync\shm\named_condition.hpp(204): error C2064: term does not evaluate to a function taking 0 arguments - Trey

On Mon, Jul 9, 2012 at 11:58 AM, Joseph Van Riper < fleeb.fantastique@gmail.com> wrote:
int _tmain(int argc, _TCHAR* argv[]) { boost::interprocess::named_mutex mutex( boost::interprocess::open_or_create, "test" ); boost::interprocess::named_condition condition( boost::interprocess::open_or_create, "test" ); condition.wait( mutex ); return 0; }
I see now that I am using a naked boost::interprocess::named_mutex when I should use a boost::interprocess::scoped_lock around it instead, as: int _tmain(int argc, _TCHAR* argv[]) { boost::interprocess::named_mutex mutex( boost::interprocess::open_or_create, "test" ); boost::interprocess::named_condition condition( boost::interprocess::open_or_create, "test" ); boost::interprocess::scoped_lock< boost::interprocess::named_mutex
lock( mutex ); condition.wait( lock ); return 0; }
- Trey

El 09/07/2012 17:58, Joseph Van Riper escribió:
I have either not understood the documentation, or found a bug in Boost.Interprocess's named_condition class. If I'm in error, I hope someone can help me. Otherwise, I will need to approach my needs another way.
Thanks for the report, can you please fill a ticket? Best, Ion

On Wed, Jul 11, 2012 at 6:57 AM, Ion Gaztañaga <igaztanaga@gmail.com> wrote:
Thanks for the report, can you please fill a ticket?
Done. It turns out to be a very minor issue, but one that could help someone just learning the library to use it more effectively. - Trey
participants (2)
-
Ion Gaztañaga
-
Joseph Van Riper