Opened 10 years ago
Last modified 7 years ago
#7682 reopened Bugs
boost 1.52 named_mutex/named_condition pairing broken
Reported by: | Owned by: | Ion Gaztañaga | |
---|---|---|---|
Milestone: | To Be Determined | Component: | interprocess |
Version: | Boost 1.52.0 | Severity: | Showstopper |
Keywords: | Cc: |
Description
The following program works in boost 1.47, however in 1.52 it does not. To test it, run 2 instances. The 2nd instance should output the numbers 1, 3, 5, 7, 9.
Under 1.52, the program outputs the number 1, and then does nothing. The fault appears to be with the named_condition and named_mutex classes.
Tested under Windows 7 Pro, SP1, using Visual Studio 2010 v10.0.40219.1 SP1Rel. The test was done with a statically linked boost date time, with Platform Toolset set to v90, i.e. linked with the library 'libboost_date_time-vc90-mt-sgd-1_47.lib'.
#include <boost/interprocess/managed_shared_memory.hpp> #include <boost/interprocess/sync/named_mutex.hpp> #include <boost/interprocess/sync/named_condition.hpp> #include <boost/interprocess/sync/scoped_lock.hpp> #include <iostream> int main() { boost::interprocess::managed_shared_memory managed_shm(boost::interprocess::open_or_create, "shm", 1024); int *i = managed_shm.find_or_construct<int>("Integer")(0); boost::interprocess::named_mutex named_mtx(boost::interprocess::open_or_create, "mtx"); boost::interprocess::named_condition named_cnd(boost::interprocess::open_or_create, "cnd"); boost::interprocess::scoped_lock<boost::interprocess::named_mutex> lock(named_mtx); while (*i < 10) { if (*i % 2 == 0) { ++(*i); named_cnd.notify_all(); named_cnd.wait(lock); } else { std::cout << *i << std::endl; ++(*i); named_cnd.notify_all(); named_cnd.wait(lock); } } named_cnd.notify_all(); boost::interprocess::shared_memory_object::remove("shm"); boost::interprocess::named_mutex::remove("mtx"); boost::interprocess::named_condition::remove("cnd"); }
Change History (8)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Breaking rev is 80146 "[named_/interprocess]sharable_mutex & [named_/interprocess]condition_any implemented"
comment:8 by , 7 years ago
Can you please elaborate what is not working? Current version seems to works perfectly. Boost 1.55 is two years old, can you please check that currect version (1.60.0) works as expected for you?
I can confirm this behavior on 1.52 and also in trunk, for gcc 4.7.2.