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

Commit8f26ea8

Browse files
committed
Get one test to build.
This set of changes gets one of the server tests(async_run_stop_concurrency) to build correctly.
1 parent7d35dc6 commit8f26ea8

File tree

9 files changed

+337
-88
lines changed

9 files changed

+337
-88
lines changed

‎boost/network/include/http/server.hpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
//
99
// This is the modular include file for using the HTTP Client
1010

11+
#include<boost/asio/io_service.hpp>
1112
#include<boost/network/protocol/http/server.hpp>
13+
#include<boost/network/utils/thread_pool.hpp>
14+
#include<boost/network/detail/debug.hpp>
1215

1316
#endif
Lines changed: 62 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,80 @@
1-
// Copyright 2009 (c) Tarro, Inc.
2-
// Copyright 2009 (c) Dean Michael Berris <mikhailberis@gmail.com>
3-
// Copyright 2010 (c) Glyn Matthews
4-
// Copyright 2003-2008 (c) Chris Kholhoff
1+
// Copyright 2009 Tarroo, Inc.
2+
// Copyright 2010 Glyn Matthews
3+
// Copyright 2003-2008 Chris Kholhoff
4+
// Copyright 2009-2012 Dean Michael Berris <dberris@gmail.com>
5+
// Copyright 2012 Google, Inc.
56
// Distributed under the Boost Software License, Version 1.0.
67
// (See accompanying file LICENSE_1_0.txt or copy at
78
// http://www.boost.org/LICENSE_1_0.txt)
89

910
#ifndef BOOST_NETWORK_HTTP_SERVER_HPP_
1011
#defineBOOST_NETWORK_HTTP_SERVER_HPP_
1112

12-
#include<boost/network/protocol/http/response.hpp>
13-
#include<boost/network/protocol/http/request.hpp>
14-
#include<boost/network/protocol/http/server/sync_server.hpp>
15-
#include<boost/network/protocol/http/server/async_server.hpp>
16-
#include<boost/network/protocol/http/server/parameters.hpp>
13+
#include<boost/shared_ptr.hpp>
14+
15+
namespaceboost {namespacenetwork {namespaceutils {
16+
17+
structthread_pool;
18+
19+
}// namespace utils
20+
21+
}// namespace network
22+
23+
}// namespace boost
1724

1825
namespaceboost {namespacenetwork {namespacehttp {
19-
20-
template<classTag,classHandler,classEnable =void>
21-
structserver_base {
22-
typedef unsupported_tag<Tag> type;
23-
};
24-
25-
template<classTag,classHandler>
26-
structserver_base<Tag, Handler,typename enable_if<is_async<Tag> >::type> {
27-
typedef async_server_base<Tag, Handler> type;
28-
};
29-
30-
template<classTag,classHandler>
31-
structserver_base<Tag, Handler,typename enable_if<is_sync<Tag> >::type> {
32-
typedef sync_server_base<Tag, Handler> type;
33-
};
34-
35-
template<classTag,classHandler>
36-
structbasic_server : server_base<Tag, Handler>::type
37-
{};
38-
39-
template<classHandler>
40-
structserver : server_base<tags::http_server, Handler>::type {
41-
typedeftypename server_base<tags::http_server, Handler>::type
42-
server_base;
43-
44-
BOOST_PARAMETER_CONSTRUCTOR(
45-
server, (server_base), tag,
46-
(required
47-
(address, (typename server_base::string_typeconst &))
48-
(port, (typename server_base::string_typeconst &))
49-
(in_out(handler), (Handler &)))
50-
(optional
51-
(in_out(io_service), (boost::asio::io_service &))
52-
(reuse_address, (bool))
53-
(report_aborted, (bool))
54-
(receive_buffer_size, (int))
55-
(send_buffer_size, (int))
56-
(receive_low_watermark, (int))
57-
(send_low_watermark, (int))
58-
(non_blocking_io, (int))
59-
(linger, (bool))
60-
(linger_timeout, (int)))
61-
)
62-
};
63-
64-
template<classHandler>
65-
structasync_server : server_base<tags::http_async_server, Handler>::type
66-
{
67-
typedeftypename server_base<tags::http_async_server, Handler>::type
68-
server_base;
69-
70-
BOOST_PARAMETER_CONSTRUCTOR(
71-
async_server, (server_base), tag,
72-
(required
73-
(address, (typename server_base::string_typeconst &))
74-
(port, (typename server_base::string_typeconst &))
75-
(in_out(handler), (Handler&))
76-
(in_out(thread_pool), (utils::thread_pool&)))
77-
(optional
78-
(in_out(io_service), (boost::asio::io_service&))
79-
(reuse_address, (bool))
80-
(report_aborted, (bool))
81-
(receive_buffer_size, (int))
82-
(send_buffer_size, (int))
83-
(receive_low_watermark, (int))
84-
(send_low_watermark, (int))
85-
(non_blocking_io, (bool))
86-
(linger, (bool))
87-
(linger_timeout, (int)))
88-
)
89-
};
26+
27+
classserver_options;
28+
classsync_server_impl;
29+
classasync_server_impl;
30+
classasync_server_connection;
31+
structrequest;
32+
structresponse;
33+
34+
35+
template<classSyncHandler>
36+
classsync_server {
37+
public:
38+
sync_server(server_optionsconst &options, SyncHandler &handler);
39+
voidrun();
40+
voidstop();
41+
voidlisten();
42+
~sync_server();
43+
44+
typedef http::request request;
45+
typedef http::response response;
46+
private:
47+
sync_server_impl *pimpl_;
48+
sync_server(sync_serverconst &other);// = delete
49+
sync_server&operator=(sync_server other);// = delete
50+
};
51+
52+
template<classAsyncHandler>
53+
classasync_server {
54+
public:
55+
explicitasync_server(server_optionsconst &options, AsyncHandler &handler, utils::thread_pool &pool);
56+
voidrun();
57+
voidstop();
58+
voidlisten();
59+
~async_server();
60+
61+
typedef http::request request;
62+
typedef shared_ptr<async_server_connection> connection_ptr;
63+
private:
64+
async_server_impl *pimpl_;
65+
async_server(async_serverconst &other);// = delete
66+
async_server&operator=(async_server other);// = delete
67+
};
9068

9169
}// namespace http
9270

9371
}// namespace network
9472

9573
}// namespace boost
9674

75+
// We're hiding the implementation from here, but still explicitly including
76+
// it here. This is mostly a style point, to keep this header clean.
77+
#include<boost/network/protocol/http/server/server.ipp>
78+
9779
#endif// BOOST_NETWORK_HTTP_SERVER_HPP_
9880

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_20120318
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_20120318
3+
4+
// Copyright 2012 Dean Michael Berris <dberris@google.com>.
5+
// Copyright 2012 Google, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include<boost/function.hpp>
11+
#include<boost/shared_ptr.hpp>
12+
13+
namespaceboost {namespacenetwork {namespaceutils {
14+
15+
structthread_pool;
16+
17+
}// namespace util
18+
19+
}// namespace network
20+
21+
}// namespace boost
22+
23+
namespaceboost {namespacenetwork {namespacehttp {
24+
25+
classasync_server_connection;
26+
27+
classasync_server_impl {
28+
public:
29+
typedef shared_ptr<async_server_connection> connection_ptr;
30+
async_server_impl(server_optionsconst &options,
31+
function<void(requestconst &, connection_ptr)> handler,
32+
utils::thread_pool &thread_pool);
33+
voidrun();
34+
voidstop();
35+
voidlisten();
36+
37+
private:
38+
server_options options_;
39+
std::string address_, port_;
40+
asio::io_service *service_;
41+
asio::ip::tcp::acceptor *acceptor_;
42+
shared_ptr<async_server_connection> new_connection_;
43+
mutex listening_mutex_;
44+
bool listening_, owned_service_;
45+
function<void(requestconst &, connection_ptr)> handler_;
46+
utils::thread_pool &pool_;
47+
};
48+
49+
}// namespace http
50+
51+
}// namespace network
52+
53+
}// namespace boost
54+
55+
#endif// BOOST_NETWORK_PROTOCOL_HTTP_SERVER_ASYNC_IMPL_20120318
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_HPP_20120318
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_HPP_20120318
3+
4+
// Copyright 2012 Dean Michael Berris <dberris@google.com>.
5+
// Copyright 2012 Google, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include<string>
11+
12+
namespaceboost {namespaceasio {
13+
14+
classio_service;
15+
16+
}// namespace asio
17+
18+
}// namespace boost
19+
20+
namespaceboost {namespacenetwork {namespacehttp {
21+
22+
classserver_options_pimpl;
23+
24+
classserver_options {
25+
public:
26+
server_options();
27+
server_options(server_optionsconst &other);
28+
voidswap(server_options &other);
29+
server_options&operator=(server_options rhs);
30+
31+
server_options&address(std::stringconst &address="0.0.0.0");
32+
std::stringconstaddress()const;
33+
34+
server_options&port(std::stringconst &port="80");
35+
std::stringconstport()const;
36+
37+
server_options&io_service(asio::io_service *service =0);
38+
asio::io_service *io_service()const;
39+
40+
server_options&reuse_address(bool setting=true);
41+
boolreuse_address();
42+
43+
server_options&report_aborted(bool setting=false);
44+
boolreport_aborted();
45+
46+
// Set the receive buffer size for a socket. -1 means just use the default.
47+
server_options&receive_buffer_size(int buffer_size=-1);
48+
intreceive_buffer_size();
49+
50+
// Set the send buffer size for a socket. -1 means just use the default.
51+
server_options&send_buffer_size(int buffer_size=-1);
52+
intsend_buffer_size();
53+
54+
// Set the receive low watermark for a socket. -1 means just use the default.
55+
server_options&receive_low_watermark(int low_watermark=-1);
56+
intreceive_low_watermark();
57+
58+
// Set the send low watermark for a socket. -1 means just use the default.
59+
server_options&send_low_watermark(int low_watermark=-1);
60+
intsend_low_watermark();
61+
62+
server_options&non_blocking_io(bool setting=true);
63+
boolnon_blocking_io();
64+
65+
server_options&linger(bool setting=false);
66+
boollinger();
67+
68+
// Set the socket linger timeout. This is only relevant if linger is true
69+
// (see linger above). -1 means just use the default.
70+
server_options&linger_timeout(int setting=-1);
71+
intlinger_timeout();
72+
73+
private:
74+
server_options_pimpl *pimpl_;
75+
};
76+
77+
}// namespace http
78+
79+
}// namespace network
80+
81+
}// namespace boost
82+
83+
#endif// BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_HPP_20120318
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SERVER_IPP_20120318
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_SERVER_SERVER_IPP_20120318
3+
4+
// Copyright 2012 Dean Michael Berris <dberris@google.com>.
5+
// Copyright 2012 Google, Inc.
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include<boost/network/protocol/http/server/options.hpp>
11+
#include<boost/network/protocol/http/server/sync_impl.hpp>
12+
#include<boost/network/protocol/http/server/async_impl.hpp>
13+
14+
namespaceboost {namespacenetwork {namespacehttp {
15+
16+
template<classSyncHandler>
17+
sync_server<SyncHandler>::sync_server(server_optionsconst &options, SyncHandler &handler)
18+
: pimpl_(new sync_server_impl(options, handler))
19+
{}
20+
21+
template<classSyncHandler>
22+
void sync_server<SyncHandler>::run() {
23+
pimpl_->run();
24+
}
25+
26+
template<classSyncHandler>
27+
void sync_server<SyncHandler>::stop() {
28+
pimpl_->stop();
29+
}
30+
31+
template<classSyncHandler>
32+
void sync_server<SyncHandler>::listen() {
33+
pimpl_->listen();
34+
}
35+
36+
template<classSyncHandler>
37+
sync_server<SyncHandler>::~sync_server() {
38+
delete pimpl_;
39+
}
40+
41+
template<classAsyncHandler>
42+
async_server<AsyncHandler>::async_server(server_optionsconst &options, AsyncHandler &handler, utils::thread_pool &pool)
43+
: pimpl_(new async_server_impl(options, handler, pool))
44+
{}
45+
46+
template<classAsyncHandler>
47+
void async_server<AsyncHandler>::run() {
48+
pimpl_->run();
49+
}
50+
51+
template<classAsyncHandler>
52+
void async_server<AsyncHandler>::stop() {
53+
pimpl_->stop();
54+
}
55+
56+
template<classAsyncHandler>
57+
void async_server<AsyncHandler>::listen() {
58+
pimpl_->listen();
59+
}
60+
61+
template<classSyncHandler>
62+
async_server<SyncHandler>::~async_server() {
63+
delete pimpl_;
64+
}
65+
66+
}// namespace http
67+
68+
}// namespace network
69+
70+
}// namespace boost
71+
72+
#endif// BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SERVER_IPP_20120318

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp