• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2010 Vicente Botet
2 //
3 //  Distributed under the Boost Software License, Version 1.0. (See accompanying
4 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 #define BOOST_THREAD_VERSION 2
7 #define BOOST_THREAD_USES_LOG
8 
9 #include <iostream>
10 #include <boost/thread/thread_only.hpp>
11 #include <boost/thread/detail/log.hpp>
12 
thread()13 void thread()
14 {
15   BOOST_THREAD_LOG << "<thrd" << BOOST_THREAD_END_LOG;
16   try {
17   boost::this_thread::sleep_for(boost::chrono::seconds(30));
18   } catch (...)
19   {
20     BOOST_THREAD_LOG << "thrd exception" << BOOST_THREAD_END_LOG;
21     throw;
22   }
23   //while (1)     ; // Never quit
24   BOOST_THREAD_LOG << "thrd>" << BOOST_THREAD_END_LOG;
25 }
26 
27 boost::thread example(thread);
28 
main()29 int main()
30 {
31   BOOST_THREAD_LOG << "<main" << BOOST_THREAD_END_LOG;
32   boost::this_thread::sleep_for(boost::chrono::seconds(30));
33   BOOST_THREAD_LOG << "main" << BOOST_THREAD_END_LOG;
34   //while (1)     ; // Never quit
35   example.join();
36   BOOST_THREAD_LOG << "main>" << BOOST_THREAD_END_LOG;
37   return 0;
38 }
39 
40