/*============================================================================= Copyright (c) 2003 Martin Wille http://spirit.sourceforge.net/ Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ // see http://article.gmane.org/gmane.comp.parsers.spirit.general/4575 // or https://sf.net/mailarchive/forum.php?thread_id=2692308&forum_id=1595 // for a description of the bug being tested for by this program // // the problem should be solved with version 1.3 of phoenix/closures.hpp> #if defined(BOOST_SPIRIT_DEBUG) && defined(__GNUC__) && defined(__WIN32__) // It seems that MinGW has some problems with threads and iostream ? // This code crashes MinGW when BOOST_SPIRIT_DEBUG is defined. The reason // is beyond me. Disable BOOST_SPIRIT_DEBUG for now. #undef BOOST_SPIRIT_DEBUG #endif #include #include #include #if defined(DONT_HAVE_BOOST) || !defined(BOOST_HAS_THREADS) || defined(BOOST_DISABLE_THREADS) // we end here if we can't do multithreading static void skipped() { std::cout << "skipped\n"; } int main() { skipped(); return boost::report_errors(); } #else // the real MT stuff #undef BOOST_SPIRIT_THREADSAFE #define BOOST_SPIRIT_THREADSAFE #undef PHOENIX_THREADSAFE #define PHOENIX_THREADSAFE #include #include #include static const int number_of_calls_to_parse_per_thread=20000; struct test_closure : BOOST_SPIRIT_CLASSIC_NS::closure { member1 b; }; struct test_grammar : BOOST_SPIRIT_CLASSIC_NS::grammar { test_grammar() {} template struct definition { definition(test_grammar const &self) { using namespace phoenix; rule = BOOST_SPIRIT_CLASSIC_NS::epsilon_p[self.b = arg1]; } BOOST_SPIRIT_CLASSIC_NS::rule const &start() const { return rule; } BOOST_SPIRIT_CLASSIC_NS::rule rule; }; }; test_grammar const g; void in_thread(void) { char const text[]="foo"; for(int i=0; i