1 /*=============================================================================
2 Copyright (c) 2003 Martin Wille
3 Copyright (c) 2001-2007 Joel de Guzman
4 Copyright (c) 2015 John Fletcher
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 =============================================================================*/
10 // see http://article.gmane.org/gmane.comp.parsers.spirit.general/4575
11 // or https://sf.net/mailarchive/forum.php?thread_id=2692308&forum_id=1595
12 // for a description of the bug being tested for by this program
14 // This code is borrowed from Spirit's bug_000008.cpp test for multithreads.
15 // Now modified to point to the Phoenix headers
16 // instead of the ones in Spirit.
18 #include <boost/config.hpp>
19 #include <boost/assert.hpp>
20 #include <boost/detail/lightweight_test.hpp>
21 // Testing problems in thread/future
22 //#include <boost/move/move.hpp>
23 //#include <boost/move/detail/type_traits.hpp>
24 //using boost::move_detail::is_copy_constructible;
25 #include <boost/phoenix/scope/dynamic.hpp>
27 #if defined(DONT_HAVE_BOOST) \
28 || !defined(BOOST_HAS_THREADS) \
29 || defined(BOOST_DISABLE_THREADS) \
30 || (defined(__GNUC__) && defined(__WIN32__)) // MinGW
35 #if defined(SKIP_TEST)
36 // we end here if we can't do multithreading
39 std::cout
<< "skipped\n";
46 return boost::report_errors();
52 #include <boost/phoenix/operator.hpp>
53 #include <boost/phoenix/scope.hpp>
54 #include <boost/thread.hpp>
56 static const int number_of_calls_per_thread
=20000;
58 struct test_dynamic
: boost::phoenix::dynamic
<int>
60 // test_dynamic() : b(*this) {}
61 test_dynamic() : b(init
<0>(this)) {}
68 test_dynamic s
; // should now be a local
70 for (int i
= 0; i
< number_of_calls_per_thread
; ++i
)
72 boost::phoenix::dynamic_frame
<test_dynamic::self_type
> frame(s
);
75 boost::phoenix::dynamic_frame
<test_dynamic::self_type
> frame(s
);
77 BOOST_ASSERT((s
.b
== 456)());
79 BOOST_ASSERT((s
.b
== 123)());
86 boost::thread
t1(in_thread
);
87 boost::thread
t2(in_thread
);
88 boost::thread
t3(in_thread
);
89 boost::thread
t4(in_thread
);
101 return boost::report_errors();