2 // detail/posix_thread.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_ASIO_DETAIL_POSIX_THREAD_HPP
12 #define BOOST_ASIO_DETAIL_POSIX_THREAD_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
20 #if defined(BOOST_ASIO_HAS_PTHREADS)
23 #include <boost/asio/detail/noncopyable.hpp>
25 #include <boost/asio/detail/push_options.hpp>
33 BOOST_ASIO_DECL void* boost_asio_detail_posix_thread_function(void* arg);
41 template <typename Function>
42 posix_thread(Function f, unsigned int = 0)
45 start_thread(new func<Function>(f));
49 BOOST_ASIO_DECL ~posix_thread();
51 // Wait for the thread to exit.
52 BOOST_ASIO_DECL void join();
55 friend void* boost_asio_detail_posix_thread_function(void* arg);
60 virtual ~func_base() {}
61 virtual void run() = 0;
64 struct auto_func_base_ptr
67 ~auto_func_base_ptr() { delete ptr; }
70 template <typename Function>
89 BOOST_ASIO_DECL void start_thread(func_base* arg);
99 #include <boost/asio/detail/pop_options.hpp>
101 #if defined(BOOST_ASIO_HEADER_ONLY)
102 # include <boost/asio/detail/impl/posix_thread.ipp>
103 #endif // defined(BOOST_ASIO_HEADER_ONLY)
105 #endif // defined(BOOST_ASIO_HAS_PTHREADS)
107 #endif // BOOST_ASIO_DETAIL_POSIX_THREAD_HPP