| 1 | // Copyright 2022 Peter Dimov |
|---|---|
| 2 | // Distributed under the Boost Software License, Version 1.0. |
| 3 | // https://www.boost.org/LICENSE_1_0.txt |
| 4 | |
| 5 | #include "boost/thread/scoped_thread.hpp" |
| 6 | #include "boost/thread.hpp" |
| 7 | #include <boost/core/lightweight_test.hpp> |
| 8 | #include <iostream> |
| 9 | |
| 10 | static void inner_thread_func() |
| 11 | { |
| 12 | boost::this_thread::sleep_for( |
| 13 | d: boost::chrono::hours(1) ); |
| 14 | } |
| 15 | |
| 16 | static void outer_thread_func() |
| 17 | { |
| 18 | boost::scoped_thread<boost::interrupt_and_join_if_joinable> inner( inner_thread_func ); |
| 19 | } |
| 20 | |
| 21 | static void double_interrupt() |
| 22 | { |
| 23 | boost::scoped_thread<boost::interrupt_and_join_if_joinable> outer( outer_thread_func ); |
| 24 | } |
| 25 | |
| 26 | int main() |
| 27 | { |
| 28 | BOOST_TEST( true ); // perform lwt initialization |
| 29 | |
| 30 | std::cout << "Start"<< std::endl; |
| 31 | double_interrupt(); |
| 32 | std::cout << "End"<< std::endl; |
| 33 | |
| 34 | return boost::report_errors(); |
| 35 | } |
| 36 |
