// // Copyright (c) 2008 João Abecasis // // Distributed under 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) // #include #include #include #include void test_get_url() { // Nothing fancy here. saga::session s; saga::filesystem::directory dir(s, "./"); saga::task t = // dir.get_url(); dir.get_url(); // dir.get_url(); } volatile bool graceful_exit = false; volatile bool run_trigger = true; volatile std::size_t loop_count = 0; void race_trigger() { // Trying to trigger a race condition while (run_trigger) { ++loop_count; test_get_url(); } // Success! graceful_exit = true; std::cout << "Exiting the race triggering loop.\n" << std::flush; } int main() { boost::timer timer; // Start race trigger in the background. boost::thread thr(race_trigger); { // Give trigger some time to work its magic. boost::xtime t; boost::xtime_get(&t, boost::TIME_UTC); t.sec += 58; boost::thread::sleep(t); // Alright, that's enough. run_trigger = false; // Give the background thread some time to exit gracefully. t.sec += 2; boost::thread::sleep(t); } std::cout << loop_count << " iterations in " << timer.elapsed() << " seconds.\n" << std::flush; exit(!graceful_exit); }