1 // Distributed under the Boost Software License, Version 1.0. (See
2 // accompanying file LICENSE_1_0.txt or copy at
3 // http://www.boost.org/LICENSE_1_0.txt)
4 // (C) Copyright 2009-2012 Anthony Williams
5 // (C) Copyright 2012 Vicente J. Botet Escriba
7 // Based on the Anthony's idea of thread_joiner in CCiA
9 #ifndef BOOST_THREAD_THREAD_GUARD_HPP
10 #define BOOST_THREAD_THREAD_GUARD_HPP
12 #include <boost/thread/detail/delete.hpp>
13 #include <boost/thread/detail/move.hpp>
14 #include <boost/thread/thread_functors.hpp>
16 #include <boost/config/abi_prefix.hpp>
22 * Non-copyable RAII scoped thread guard joiner which join the thread if joinable when destroyed.
24 template <class CallableThread = join_if_joinable, class Thread=::boost::thread>
29 BOOST_THREAD_NO_COPYABLE( thread_guard)
31 explicit thread_guard(Thread& t) :
37 CallableThread on_destructor;
44 #include <boost/config/abi_suffix.hpp>