diff options
Diffstat (limited to 'src/boost/libs/thread/test/test_7328.cpp')
-rw-r--r-- | src/boost/libs/thread/test/test_7328.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/boost/libs/thread/test/test_7328.cpp b/src/boost/libs/thread/test/test_7328.cpp new file mode 100644 index 000000000..0c0cca03a --- /dev/null +++ b/src/boost/libs/thread/test/test_7328.cpp @@ -0,0 +1,47 @@ +// Copyright (C) 2010 Vicente Botet +// +// 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) + +#define BOOST_THREAD_PROVIDES_INTERRUPTIONS + +#include <iostream> +#include <boost/thread/thread_only.hpp> +#include <boost/detail/lightweight_test.hpp> + +#if defined BOOST_THREAD_USES_CHRONO + +//using namespace boost; +using namespace boost::chrono; + +bool interrupted = false; +void f() +{ + try + { + std::cout << "Starting sleep in thread" << std::endl; + for (;;) + { + boost::this_thread::sleep_for(seconds(60)); + } + } + catch (const boost::thread_interrupted&) + { + interrupted = true; + std::cout << "Thread interrupted." << std::endl; + } +} + +int main() +{ + boost::thread t(f); + t.interrupt(); + t.join(); + std::cout << "Joined with thread." << std::endl; + BOOST_TEST(interrupted); + return boost::report_errors(); +} + +#else +#error "Test not applicable: BOOST_THREAD_USES_CHRONO not defined for this platform as not supported" +#endif |