2
0
mirror of https://github.com/boostorg/thread.git synced 2026-01-24 18:32:32 +00:00
Files
thread/test/test_7328.cpp
Vicente J. Botet Escriba 2e5bc32b33 Thread: try to fix 7238
[SVN r80076]
2012-08-18 11:26:51 +00:00

40 lines
819 B
C++

// 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)
#include <iostream>
#include <boost/thread.hpp>
#include <boost/detail/lightweight_test.hpp>
using namespace boost;
using namespace boost::chrono;
bool interrupted = false;
void f()
{
try
{
std::cout << "Starting sleep in thread" << std::endl;
while (true)
{
this_thread::sleep_for(seconds(60));
}
}
catch (const thread_interrupted&)
{
interrupted = true;
std::cout << "Thread interrupted." << std::endl;
}
}
int main()
{
thread t(f);
t.interrupt();
t.join();
std::cout << "Joined with thread." << std::endl;
BOOST_TEST(interrupted);
return boost::report_errors();
}