#include <iostream>
#include <boost/config.hpp>
#include <boost/assert.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/phoenix/scope/dynamic.hpp>
#if defined(DONT_HAVE_BOOST) \
|| !defined(BOOST_HAS_THREADS) \
|| defined(BOOST_DISABLE_THREADS) \
|| (defined(__GNUC__) && defined(__WIN32__))
#define SKIP_TEST
#endif
#if defined(SKIP_TEST)
static void skipped()
{
std::cout << "skipped\n";
}
int
main()
{
skipped();
return boost::report_errors();
}
#else
#include <boost/phoenix/operator.hpp>
#include <boost/phoenix/scope.hpp>
#include <boost/thread.hpp>
static const int number_of_calls_per_thread=20000;
struct test_dynamic : boost::phoenix::dynamic<int>
{
test_dynamic() : b(init<0>(this)) {}
member1 b;
};
void
in_thread(void)
{
test_dynamic s;
for (int i = 0; i < number_of_calls_per_thread; ++i)
{
boost::phoenix::dynamic_frame<test_dynamic::self_type> frame(s);
(s.b = 123)();
{
boost::phoenix::dynamic_frame<test_dynamic::self_type> frame(s);
(s.b = 456)();
BOOST_ASSERT((s.b == 456)());
}
BOOST_ASSERT((s.b == 123)());
}
}
void
bug_000008()
{
boost::thread t1(in_thread);
boost::thread t2(in_thread);
boost::thread t3(in_thread);
boost::thread t4(in_thread);
t1.join();
t2.join();
t3.join();
t4.join();
}
int
main()
{
bug_000008();
return boost::report_errors();
}
#endif