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
10static void inner_thread_func()
11{
12 boost::this_thread::sleep_for(
13 d: boost::chrono::hours(1) );
14}
15
16static void outer_thread_func()
17{
18 boost::scoped_thread<boost::interrupt_and_join_if_joinable> inner( inner_thread_func );
19}
20
21static void double_interrupt()
22{
23 boost::scoped_thread<boost::interrupt_and_join_if_joinable> outer( outer_thread_func );
24}
25
26int 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

source code of boost/libs/thread/test/test_366_2.cpp