Subject: [Boost-bugs] [Boost C++ Libraries] #7682: boost 1.52 named_mutex/named_condition pairing broken
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-11-13 00:00:48
#7682: boost 1.52 named_mutex/named_condition pairing broken
----------------------------------------+-----------------------------------
Reporter: damian.coventry@⦠| Owner: igaztanaga
Type: Bugs | Status: new
Milestone: To Be Determined | Component: interprocess
Version: Boost 1.52.0 | Severity: Showstopper
Keywords: |
----------------------------------------+-----------------------------------
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");
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/7682> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:11 UTC