Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit43efa98

Browse files
committed
Updated thread pool documentation.
1 parent4d2389b commit43efa98

File tree

3 files changed

+77
-22
lines changed

3 files changed

+77
-22
lines changed

‎Doxyfile.in‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ FULL_PATH_NAMES = YES
130130

131131
STRIP_FROM_PATH = @CMAKE_CURRENT_SOURCE_DIR@/error/src/ \
132132
@CMAKE_CURRENT_SOURCE_DIR@/uri/src/ \
133-
@CMAKE_CURRENT_SOURCE_DIR@/http/src/
133+
@CMAKE_CURRENT_SOURCE_DIR@/http/src/ \
134+
@CMAKE_CURRENT_SOURCE_DIR@/concurrency/src/
134135

135136
# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
136137
# the path mentioned in the documentation of a class, which tells
@@ -652,7 +653,8 @@ WARN_LOGFILE =
652653

653654
INPUT = @CMAKE_CURRENT_SOURCE_DIR@/error/ \
654655
@CMAKE_CURRENT_SOURCE_DIR@/uri/src/network/ \
655-
@CMAKE_CURRENT_SOURCE_DIR@/http/src/network/http/
656+
@CMAKE_CURRENT_SOURCE_DIR@/http/src/network/http/ \
657+
@CMAKE_CURRENT_SOURCE_DIR@/concurrency/src/network/
656658

657659
# This tag can be used to specify the character encoding of the source files
658660
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
@@ -849,7 +851,8 @@ COLS_IN_ALPHA_INDEX = 5
849851

850852
IGNORE_PREFIX = @CMAKE_CURRENT_SOURCE_DIR@/error/src/ \
851853
@CMAKE_CURRENT_SOURCE_DIR@/uri/src/ \
852-
@CMAKE_CURRENT_SOURCE_DIR@/http/src/
854+
@CMAKE_CURRENT_SOURCE_DIR@/http/src/ \
855+
@CMAKE_CURRENT_SOURCE_DIR@/concurrency/src/
853856

854857
#---------------------------------------------------------------------------
855858
# configuration options related to the HTML output

‎concurrency/src/network/concurrency/thread_pool.hpp‎

Lines changed: 64 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
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-
#defineNETWORK_CONCURRENCY_THREAD_POOL_HPP_20101020
8+
#ifndef NETWORK_CONCURRENCY_THREAD_POOL_INC
9+
#defineNETWORK_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 {
2232
typedef std::shared_ptr<std::vector<std::thread>> worker_threads_ptr;
2333
typedef std::shared_ptr<boost::asio::io_service::work> sentinel_ptr;
2434

25-
structthread_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+
classthread_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+
voidswap(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_tconstthread_count()const;
37-
voidpost(std::function<void()> f);
38-
voidswap(thread_pool& other);
85+
86+
/**
87+
* \brief Posts a task to the thread pool.
88+
* \param task The task to be executed.
89+
*/
90+
voidpost(std::function<void()> task);
3991

4092
private:
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

‎concurrency/src/network/concurrency/thread_pool.ipp‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ namespace network {
1717
namespaceconcurrency {
1818

1919
structthread_pool::impl {
20-
impl(std::size_tthreads =1,
20+
impl(std::size_tthread_count =1,
2121
io_service_ptr io_service = io_service_ptr(),
2222
std::vector<std::thread> worker_threads = std::vector<std::thread>())
23-
:threads_(threads),
23+
:thread_count_(thread_count),
2424
io_service_(io_service),
2525
worker_threads_(std::move(worker_threads)),
2626
sentinel_() {
@@ -49,7 +49,7 @@ namespace network {
4949
}
5050

5151
auto local_io_service = io_service_;
52-
for (std::size_t counter =0; counter <threads_; ++counter) {
52+
for (std::size_t counter =0; counter <thread_count_; ++counter) {
5353
worker_threads_.emplace_back([local_io_service]() {
5454
local_io_service->run();
5555
});
@@ -71,23 +71,23 @@ namespace network {
7171
}
7272
}
7373

74-
std::size_tthreads_;
74+
std::size_tthread_count_;
7575
io_service_ptr io_service_;
7676
std::vector<std::thread> worker_threads_;
7777
sentinel_ptr sentinel_;
7878

7979
};
8080

81-
thread_pool::thread_pool(std::size_tthreads,
81+
thread_pool::thread_pool(std::size_tthread_count,
8282
io_service_ptr io_service,
8383
std::vector<std::thread> worker_threads)
8484
: pimpl_(new (std::nothrow)
85-
impl(threads, io_service, std::move(worker_threads))) {
85+
impl(thread_count, io_service, std::move(worker_threads))) {
8686

8787
}
8888

8989
std::size_tconstthread_pool::thread_count()const {
90-
return pimpl_->threads_;
90+
return pimpl_->thread_count_;
9191
}
9292

9393
voidthread_pool::post(std::function<void()> f) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp