// // 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 #include void test_get_url() { saga::filesystem::directory dir(saga::url("./")); saga::task t = // dir.get_url(); dir.get_url(); // dir.get_url(); } volatile std::size_t loop_count = 0; int main() { // Trying to trigger a race condition while (true) { ++loop_count; test_get_url(); } } boost::timer timer; void stop() { std::clog << loop_count << " iterations in " << timer.elapsed() << " seconds." << std::endl; exit(0); } struct time_bomb { template time_bomb(Func f, int secs) { boost::thread thr(boost::bind(&_run, f, secs)); } private: template static void _run(Func f, int secs) { boost::xtime t; boost::xtime_get(&t, boost::TIME_UTC); t.sec += secs; boost::thread::sleep(t); f(); } }; time_bomb timeout (&stop, 180);