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

Commit8797e4d

Browse files
committed
Removed dependency on boost thread, including for examples.
1 parentd601264 commit8797e4d

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

‎CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ add_definitions(-DBOOST_TEST_DYN_LINK)
4747
set(Boost_USE_MULTI_THREADEDON)
4848

4949
find_package(Boost 1.57.0
50-
REQUIREDsystemthreadfilesystem program_options)
50+
REQUIREDsystem filesystem program_options)
5151

5252
if (CPP-NETLIB_ENABLE_HTTPS)
5353
find_package( OpenSSL )

‎libs/network/example/http/fileserver.cpp‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// http://www.boost.org/LICENSE_1_0.txt)
55

66
#include<memory>
7+
#include<thread>
78
#include<boost/network/include/http/server.hpp>
8-
#include<boost/thread.hpp>
99
#include<sys/mman.h>
1010
#include<sys/types.h>
1111
#include<sys/stat.h>
@@ -28,7 +28,7 @@ struct file_cache {
2828
std::string doc_root_;
2929
region_map regions;
3030
meta_map file_headers;
31-
boost::shared_mutex cache_mutex;
31+
std::mutex cache_mutex;
3232

3333
explicitfile_cache(std::string doc_root) : doc_root_(std::move(doc_root)) {}
3434

@@ -39,12 +39,12 @@ struct file_cache {
3939
}
4040

4141
boolhas(std::stringconst &path) {
42-
boost::shared_lock<boost::shared_mutex>lock(cache_mutex);
42+
std::unique_lock<std::mutex>lock(cache_mutex);
4343
return regions.find(doc_root_ + path) != regions.end();
4444
}
4545

4646
booladd(std::stringconst &path) {
47-
boost::upgrade_lock<boost::shared_mutex>lock(cache_mutex);
47+
std::unique_lock<std::mutex>lock(cache_mutex);
4848
std::string real_filename = doc_root_ + path;
4949
if (regions.find(real_filename) != regions.end())returntrue;
5050
#ifdef O_NOATIME
@@ -60,7 +60,6 @@ struct file_cache {
6060
returnfalse;
6161
}
6262

63-
boost::upgrade_to_unique_lock<boost::shared_mutex>unique_lock(lock);
6463
regions.insert(std::make_pair(real_filename,std::make_pair(region, size)));
6564
static server::response_header common_headers[] = {
6665
{"Connection","close"}, {"Content-Type","x-application/octet-stream"},
@@ -73,7 +72,7 @@ struct file_cache {
7372
}
7473

7574
std::pair<void *, std::size_t>get(std::stringconst &path) {
76-
boost::shared_lock<boost::shared_mutex>lock(cache_mutex);
75+
std::unique_lock<std::mutex>lock(cache_mutex);
7776
region_map::const_iterator region = regions.find(doc_root_ + path);
7877
if (region != regions.end())
7978
return region->second;
@@ -83,14 +82,12 @@ struct file_cache {
8382

8483
boost::iterator_range<std::vector<server::response_header>::iterator>meta(
8584
std::stringconst &path) {
86-
boost::shared_lock<boost::shared_mutex>lock(cache_mutex);
85+
std::unique_lock<std::mutex>lock(cache_mutex);
8786
static std::vector<server::response_header> empty_vector;
8887
auto headers = file_headers.find(doc_root_ + path);
8988
if (headers != file_headers.end()) {
90-
auto begin = headers->second
91-
.begin(),
92-
end =
93-
headers->second.end();
89+
auto begin = headers->second.begin(),
90+
end = headers->second.end();
9491
returnboost::make_iterator_range(begin, end);
9592
}else
9693
returnboost::make_iterator_range(empty_vector);

‎libs/network/example/http/hello_world_async_server_with_work_queue.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ int main() {
167167
autoserver(std::make_shared<server_data>(
168168
server::options(request_handler)
169169
.address("0.0.0.0")
170-
.port("8800")
170+
.port("8000")
171171
.io_service(io_service)
172172
.reuse_address(true)
173173
.thread_pool(std::make_shared<boost::network::utils::thread_pool>(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp