11// Copyright 2010 Dean Michael Berris.
22// Copyright 2012 Google, Inc.
3- // Copyright (c) Glyn Matthews 2012, 2013.
3+ // Copyright (c) Glyn Matthews 2012, 2013, 2014 .
44// Distributed under the Boost Software License, Version 1.0.
55// (See accompanying file LICENSE_1_0.txt or copy at
66// http://www.boost.org/LICENSE_1_0.txt)
77
8- #ifndef NETWORK_CONCURRENCY_THREAD_POOL_HPP_20101020
9- #define NETWORK_CONCURRENCY_THREAD_POOL_HPP_20101020
8+ #ifndef NETWORK_CONCURRENCY_THREAD_POOL_INC
9+ #define NETWORK_CONCURRENCY_THREAD_POOL_INC
10+
11+ /* *
12+ * \defgroup concurrency Basic Concurrency Types
13+ *
14+ * This module contains a simple concurrency types for use inside the
15+ * cpp-netlib network libraries.
16+ *
17+ * \file
18+ * \brief Contains a thread_pool type.
19+ */
1020
1121#include < cstddef>
1222#include < thread>
@@ -22,20 +32,62 @@ namespace network {
2232typedef std::shared_ptr<std::vector<std::thread>> worker_threads_ptr;
2333typedef std::shared_ptr<boost::asio::io_service::work> sentinel_ptr;
2434
25- struct thread_pool {
26- thread_pool (std::size_t threads =1 ,
35+ /* *
36+ * \ingroup concurrency
37+ * \class thread_pool network/concurrency/thread_pool.hpp
38+ * \brief A very simple thread pool.
39+ */
40+ class thread_pool {
41+
42+ thread_pool (thread_poolconst &) =delete ;
43+ thread_pool&operator =(thread_poolconst &) =delete ;
44+
45+ public:
46+
47+ /* *
48+ * \brief Constructor.
49+ * \param thread_count The number of threads in the thread pool.
50+ * \param io_service An external io_service.
51+ * \param worker_threads An external thread pool.
52+ */
53+ thread_pool (std::size_t thread_count =1 ,
2754 io_service_ptr io_service = io_service_ptr(),
2855 std::vector<std::thread> worker_threads = std::vector<std::thread>());
29- thread_pool (thread_poolconst &) =delete ;
30- thread_pool (thread_pool && other);
56+
57+ /* *
58+ * \brief Move constuctor.
59+ * \param other The other thread_pool object.
60+ */
61+ thread_pool (thread_pool&& other);
62+
63+ /* *
64+ * \brief Destructor.
65+ */
3166~thread_pool ();
3267
33- thread_pool&operator =(thread_poolconst &) =delete ;
34- thread_pool&operator =(thread_pool && other);
68+ /* *
69+ * \brief Swap function.
70+ * \param other The other thread_pool object.
71+ */
72+ void swap (thread_pool& other);
3573
74+ /* *
75+ * \brief Move assignment operator.
76+ * \param other The other thread_pool object.
77+ */
78+ thread_pool&operator =(thread_pool&& other);
79+
80+ /* *
81+ * \brief Returns the number of threads in the thread pool.
82+ * \returns The number of threads in the thread pool.
83+ */
3684 std::size_t const thread_count ()const ;
37- void post (std::function<void ()> f);
38- void swap (thread_pool& other);
85+
86+ /* *
87+ * \brief Posts a task to the thread pool.
88+ * \param task The task to be executed.
89+ */
90+ void post (std::function<void ()> task);
3991
4092private:
4193
@@ -52,4 +104,4 @@ namespace network {
52104 }// namespace concurrency
53105}// namespace network
54106
55- #endif /* NETWORK_CONCURRENCY_THREAD_POOL_HPP_20101020 */
107+ #endif // NETWORK_CONCURRENCY_THREAD_POOL_INC