Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/thread/thread_guard.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Distributed under the Boost Software License, Version 1.0. (See
0002 // accompanying file LICENSE_1_0.txt or copy at
0003 // http://www.boost.org/LICENSE_1_0.txt)
0004 // (C) Copyright 2009-2012 Anthony Williams
0005 // (C) Copyright 2012 Vicente J. Botet Escriba
0006 
0007 // Based on the Anthony's idea of thread_joiner in CCiA
0008 
0009 #ifndef BOOST_THREAD_THREAD_GUARD_HPP
0010 #define BOOST_THREAD_THREAD_GUARD_HPP
0011 
0012 #include <boost/thread/detail/delete.hpp>
0013 #include <boost/thread/detail/move.hpp>
0014 #include <boost/thread/thread_functors.hpp>
0015 #include <boost/thread/detail/thread_interruption.hpp>
0016 
0017 #include <boost/config/abi_prefix.hpp>
0018 
0019 namespace boost
0020 {
0021 
0022   /**
0023    * Non-copyable RAII scoped thread guard joiner which join the thread if joinable when destroyed.
0024    */
0025   template <class CallableThread = join_if_joinable, class Thread=::boost::thread>
0026   class thread_guard
0027   {
0028     Thread& t_;
0029   public:
0030     BOOST_THREAD_NO_COPYABLE( thread_guard)
0031 
0032     explicit thread_guard(Thread& t) :
0033     t_(t)
0034     {
0035     }
0036     ~thread_guard()
0037     {
0038 #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
0039       // exceptions from a destructor call std::terminate
0040       boost::this_thread::disable_interruption do_not_disturb;
0041 #endif
0042       CallableThread on_destructor;
0043 
0044       on_destructor(t_);
0045     }
0046   };
0047 
0048 }
0049 #include <boost/config/abi_suffix.hpp>
0050 
0051 #endif