]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | |
6 | ||
7 | // Based on the Anthony's idea of scoped_thread in CCiA | |
8 | ||
9 | #ifndef BOOST_THREAD_THREAD_FUNCTORS_HPP | |
10 | #define BOOST_THREAD_THREAD_FUNCTORS_HPP | |
11 | ||
12 | #include <boost/thread/detail/config.hpp> | |
13 | #include <boost/thread/detail/delete.hpp> | |
14 | #include <boost/thread/detail/move.hpp> | |
15 | #include <boost/thread/thread_only.hpp> | |
16 | ||
17 | #include <boost/config/abi_prefix.hpp> | |
18 | ||
19 | namespace boost | |
20 | { | |
21 | ||
22 | struct detach | |
23 | { | |
24 | void operator()(thread& t) | |
25 | { | |
26 | t.detach(); | |
27 | } | |
28 | }; | |
29 | ||
30 | struct join_if_joinable | |
31 | { | |
32 | void operator()(thread& t) | |
33 | { | |
34 | if (t.joinable()) | |
35 | { | |
36 | t.join(); | |
37 | } | |
38 | } | |
39 | }; | |
40 | ||
41 | #if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS | |
42 | struct interrupt_and_join_if_joinable | |
43 | { | |
44 | void operator()(thread& t) | |
45 | { | |
46 | if (t.joinable()) | |
47 | { | |
48 | t.interrupt(); | |
49 | t.join(); | |
50 | } | |
51 | } | |
52 | }; | |
53 | #endif | |
54 | } | |
55 | #include <boost/config/abi_suffix.hpp> | |
56 | ||
57 | #endif |