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

Commit1fae5c5

Browse files
committed
Merge pull requestcpp-netlib#374 from glynos/master
Updates to HTTP Client V2 and documentation.
2 parentse61966e +ce177f8 commit1fae5c5

30 files changed

+566
-888
lines changed

‎CMakeLists.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ if(CPP-NETLIB_BUILD_TESTS)
135135

136136
set(GMOCK_ROOT ${CPP-NETLIB_SOURCE_DIR}/deps/gmock)
137137
set(GMOCK_FOUNDON)
138-
set(GMOCK_INCLUDE_DIRS${GTEST_INCLUDE_DIRS}{${GMOCK_DIR}/include)
139-
set(GMOCK_LIBRARY{$GTEST_LIBRARIES} gmock)
138+
set(GMOCK_INCLUDE_DIRS${GTEST_INCLUDE_DIRS}${GMOCK_ROOT}/include)
139+
set(GMOCK_LIBRARY${GTEST_LIBRARIES} gmock)
140140
set(GMOCK_MAIN_LIBRARY gmock_main)
141141
set(GMOCK_BOTH_LIBRARIES${GMOCK_LIBRARY}${GMOCK_MAIN_LIBRARY})
142142

‎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) {

‎contrib/http_examples/read_headers.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ main(int argc, char *argv[]) {
1919

2020
try {
2121
http::client client;
22-
http::client::request request{network::uri{std::string{argv[1]}}};
22+
http::request request{network::uri{std::string{argv[1]}}};
2323
request.version("1.0");
2424
request.append_header("Connection","close");
2525
request.append_header("User-Agent","cpp-netlib read_headers example");

‎contrib/http_examples/simple_wget.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
//[ simple_wget_main
88
/*`
9-
This is a very basic clone of wget.It's missing a lot of
9+
This is a very basic clone of wget. It's missing a lot of
1010
features, such as content-type detection, but it does the
1111
fundamental things the same.
1212
13-
It demonstrates the use the `uri` and the `http::client`.
13+
It demonstrates the useofthe `uri` and the `http::client`.
1414
*/
1515

1616
#include<network/http/client.hpp>
@@ -37,7 +37,7 @@ int main(int argc, char* argv[]) {
3737

3838
try {
3939
http::client client;
40-
http::client::request request{network::uri{std::string{argv[1]}}};
40+
http::request request{network::uri{std::string{argv[1]}}};
4141
request.version("1.0");
4242
request.append_header("Connection","close");
4343
request.append_header("User-Agent","cpp-netlib simple_wget example");

‎http/src/CMakeLists.txt‎

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# Copyright 2012 A. Joel Lamotte (mjklaim@gmail.com)
44
# Copyright 2011 Google, Inc.
55
# Distributed under the Boost Software License, Version 1.0.
6-
#(See accompanying file LICENSE_1_0.txt or copy at
7-
#http://www.boost.org/LICENSE_1_0.txt)
6+
# (See accompanying file LICENSE_1_0.txt or copy at
7+
# http://www.boost.org/LICENSE_1_0.txt)
88

99

1010
include_directories(
@@ -37,22 +37,6 @@ if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
3737
add_library(cppnetlib-http-message-wrappers ${CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS})
3838
endif()
3939

40-
#set(CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS
41-
# http/client_connections.cpp
42-
# http/simple_connection_manager.cpp
43-
# http/simple_connection_factory.cpp
44-
# http/connection_delegate_factory.cpp
45-
# http/client_resolver_delegate.cpp
46-
# http/client_resolver_delegate_factory.cpp
47-
# http/client_connection_delegates.cpp
48-
# http/client_connection_factory.cpp
49-
# http/client_async_resolver.cpp
50-
# http/client_connection_normal.cpp)
51-
#
52-
#if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
53-
# add_library(cppnetlib-http-client-connections ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS})
54-
#endif()
55-
5640
set(CPP-NETLIB_CONSTANTS_SRCS
5741
constants.cpp)
5842

@@ -70,26 +54,7 @@ if (NOT CPP-NETLIB_BUILD_SINGLE_LIB)
7054
add_library(cppnetlib-http-server ${CPP-NETLIB_HTTP_SERVER_SRCS})
7155
endif()
7256

73-
#set(CPP-NETLIB_HTTP_CLIENT_SRCS
74-
# http/client.cpp)
75-
#
76-
#if(NOT CPP-NETLIB_BUILD_SINGLE_LIB)
77-
# add_library(cppnetlib-http-client ${CPP-NETLIB_HTTP_CLIENT_SRCS})
78-
# target_link_libraries(cppnetlib-http-client
79-
# ${Boost_LIBRARIES}
80-
# ${CPP-NETLIB_LOGGING_LIB}
81-
# cppnetlib-constants
82-
# cppnetlib-uri
83-
# cppnetlib-message
84-
# cppnetlib-message-wrappers
85-
# cppnetlib-message-directives
86-
# cppnetlib-http-message
87-
# cppnetlib-http-message-wrappers
88-
# cppnetlib-http-client-connections
89-
# )
90-
#endif()
91-
92-
57+
# HTTP client
9358
set(CPP-NETLIB_HTTP_V2_CLIENT_SRCS
9459
${CMAKE_CURRENT_SOURCE_DIR}/http/v2/client/client.cpp
9560
${CMAKE_CURRENT_SOURCE_DIR}/http/v2/client/client_errors.cpp
@@ -99,23 +64,21 @@ target_link_libraries(network-http-v2-client
9964
${Boost_LIBRARIES}
10065
network-uri
10166
)
67+
if (OPENSSL_FOUND)
68+
target_link_libraries(network-http-v2-client${OPENSSL_LIBRARIES})
69+
endif()
10270

10371
# prepend current directory to make paths absolute
10472
prependToElements("${CMAKE_CURRENT_SOURCE_DIR}/"
10573
CPP-NETLIB_HTTP_MESSAGE_SRCS
10674
CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS
107-
# CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS
10875
CPP-NETLIB_CONSTANTS_SRCS
10976
CPP-NETLIB_HTTP_SERVER_SRCS
110-
# CPP-NETLIB_HTTP_CLIENT_SRCS
11177
CPP-NETLIB_HTTP_V2_CLIENT_SRCS )
11278

113-
11479
# propagate sources to parent directory for one-lib-build
11580
set(CPP-NETLIB_HTTP_MESSAGE_SRCS ${CPP-NETLIB_HTTP_MESSAGE_SRCS} PARENT_SCOPE)
11681
set(CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS ${CPP-NETLIB_HTTP_MESSAGE_WRAPPERS_SRCS} PARENT_SCOPE)
117-
#set(CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS ${CPP-NETLIB_HTTP_CLIENT_CONNECTIONS_SRCS} PARENT_SCOPE)
118-
#set(CPP-NETLIB_HTTP_CLIENT_SRCS ${CPP-NETLIB_HTTP_CLIENT_SRCS} PARENT_SCOPE)
11982
set(CPP-NETLIB_HTTP_SERVER_SRCS ${CPP-NETLIB_HTTP_SERVER_SRCS} PARENT_SCOPE)
12083
set(CPP-NETLIB_CONSTANTS_SRCS ${CPP-NETLIB_CONSTANTS_SRCS} PARENT_SCOPE)
12184
set(CPP-NETLIB_HTTP_V2_CLIENT_SRCS ${CPP-NETLIB_HTTP_V2_CLIENT_SRCS} PARENT SCOPE)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp