Skip to content

Commit f4f6a86

Browse files
committed
Replaced boost::mutex with std::mutex.
1 parent bd35adb commit f4f6a86

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

boost/network/protocol/http/policies/pooled_connection.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
// (See accompanying file LICENSE_1_0.txt or copy at
88
// http://www.boost.org/LICENSE_1_0.txt)
99

10+
#include <mutex>
1011
#include <boost/algorithm/string/predicate.hpp>
1112
#include <boost/network/protocol/http/client/connection/sync_base.hpp>
1213
#include <boost/network/protocol/http/response.hpp>
1314
#include <boost/network/protocol/http/traits/resolver_policy.hpp>
14-
#include <boost/thread/mutex.hpp>
1515
#include <boost/unordered_map.hpp>
1616
#include <utility>
1717

@@ -181,7 +181,7 @@ struct pooled_connection_policy : resolver_policy<Tag>::type {
181181
typedef std::shared_ptr<connection_impl> connection_ptr;
182182

183183
typedef unordered_map<string_type, std::weak_ptr<connection_impl>> host_connection_map;
184-
boost::mutex host_mutex_;
184+
std::mutex host_mutex_;
185185
host_connection_map host_connections_;
186186
bool follow_redirect_;
187187
int timeout_;
@@ -197,7 +197,7 @@ struct pooled_connection_policy : resolver_policy<Tag>::type {
197197
optional<string_type> const& ciphers = optional<string_type>()) {
198198
string_type index =
199199
(request_.host() + ':') + lexical_cast<string_type>(request_.port());
200-
boost::mutex::scoped_lock lock(host_mutex_);
200+
std::unique_lock<mutex> lock(host_mutex_);
201201
auto it = host_connections_.find(index);
202202
if (it != host_connections_.end()) {
203203
// We've found an existing connection; but we should check if that

boost/network/protocol/http/server/async_server.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
// http://www.boost.org/LICENSE_1_0.txt)
99

1010
#include <memory>
11+
#include <mutex>
1112
#include <boost/network/detail/debug.hpp>
1213
#include <boost/network/protocol/http/server/async_connection.hpp>
13-
#include <boost/thread/mutex.hpp>
1414
#include <boost/network/protocol/http/server/storage_base.hpp>
1515
#include <boost/network/protocol/http/server/socket_options_base.hpp>
1616
#include <boost/network/utils/thread_pool.hpp>
@@ -28,7 +28,7 @@ struct async_server_base : server_storage_base, socket_options_base {
2828
response_header;
2929
typedef async_connection<Tag, Handler> connection;
3030
typedef std::shared_ptr<connection> connection_ptr;
31-
typedef boost::unique_lock<boost::mutex> scoped_mutex_lock;
31+
typedef std::unique_lock<std::mutex> scoped_mutex_lock;
3232

3333
explicit async_server_base(server_options<Tag, Handler> const &options)
3434
: server_storage_base(options),
@@ -87,8 +87,8 @@ struct async_server_base : server_storage_base, socket_options_base {
8787
asio::ip::tcp::acceptor acceptor;
8888
bool stopping;
8989
connection_ptr new_connection;
90-
boost::mutex listening_mutex_;
91-
boost::mutex stopping_mutex_;
90+
std::mutex listening_mutex_;
91+
std::mutex stopping_mutex_;
9292
bool listening;
9393
std::shared_ptr<ssl_context> ctx_;
9494

boost/network/protocol/http/server/sync_server.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define BOOST_NETWORK_PROTOCOL_HTTP_SERVER_SYNC_SERVER_HPP_20101025
1010

1111
#include <memory>
12+
#include <mutex>
1213
#include <boost/network/detail/debug.hpp>
1314
#include <boost/bind.hpp>
1415
#include <boost/asio/ip/tcp.hpp>
@@ -19,7 +20,6 @@
1920
#include <boost/network/protocol/http/server/socket_options_base.hpp>
2021
#include <boost/network/protocol/http/server/options.hpp>
2122
#include <boost/network/traits/string.hpp>
22-
#include <boost/thread/mutex.hpp>
2323

2424
namespace boost {
2525
namespace network {
@@ -58,7 +58,7 @@ struct sync_server_base : server_storage_base, socket_options_base {
5858
}
5959

6060
void listen() {
61-
boost::unique_lock<boost::mutex> listening_lock(listening_mutex_);
61+
std::unique_lock<std::mutex> listening_lock(listening_mutex_);
6262
if (!listening_) start_listening();
6363
}
6464

@@ -67,7 +67,7 @@ struct sync_server_base : server_storage_base, socket_options_base {
6767
string_type address_, port_;
6868
boost::asio::ip::tcp::acceptor acceptor_;
6969
std::shared_ptr<sync_connection<Tag, Handler> > new_connection;
70-
boost::mutex listening_mutex_;
70+
std::mutex listening_mutex_;
7171
bool listening_;
7272

7373
void handle_accept(boost::system::error_code const& ec) {

libs/network/example/http/hello_world_async_server_with_work_queue.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
#include <memory>
11+
#include <mutex>
1112
#include <boost/network/include/http/server.hpp>
1213
#include <boost/network/uri.hpp>
1314

@@ -46,16 +47,16 @@ struct work_queue {
4647
typedef std::list<request_data::pointer> list;
4748

4849
list requests;
49-
boost::mutex mutex;
50+
std::mutex mutex;
5051

5152
inline void put(const request_data::pointer& p_rd) {
52-
boost::unique_lock<boost::mutex> lock(mutex);
53+
std::unique_lock<std::mutex> lock(mutex);
5354
requests.push_back(p_rd);
5455
(void)lock;
5556
}
5657

5758
inline request_data::pointer get() {
58-
boost::unique_lock<boost::mutex> lock(mutex);
59+
std::unique_lock<std::mutex> lock(mutex);
5960

6061
request_data::pointer p_ret;
6162
if (!requests.empty()) {

0 commit comments

Comments
 (0)