1
+ #include < thread>
2
+ #include < chrono>
1
3
#include < boost/network/include/http/server.hpp>
2
- #include < boost/thread.hpp>
3
4
4
5
namespace http = boost::network::http;
5
6
namespace util = boost::network::utils;
@@ -23,7 +24,7 @@ int main(int, char*[]) {
23
24
#define ASYNC_SERVER_TEST_CONFIG \
24
25
options.address (" 127.0.0.1" ).port (" 8007" ).reuse_address (true )
25
26
26
- #define ASYNC_SERVER_SLEEP_TIME boost::posix_time ::milliseconds (100 )
27
+ #define ASYNC_SERVER_SLEEP_TIME std::chrono ::milliseconds (100 )
27
28
28
29
// stop from main thread
29
30
{
@@ -39,9 +40,9 @@ int main(int, char*[]) {
39
40
async_server::options options (async_handler);
40
41
async_server server_instance (ASYNC_SERVER_TEST_CONFIG);
41
42
42
- boost ::thread running_thread (
43
+ std ::thread running_thread (
43
44
boost::bind (&async_server::run, &server_instance));
44
- boost ::this_thread::sleep (ASYNC_SERVER_SLEEP_TIME);
45
+ std ::this_thread::sleep_for (ASYNC_SERVER_SLEEP_TIME);
45
46
46
47
server_instance.stop ();
47
48
running_thread.join ();
@@ -53,13 +54,13 @@ int main(int, char*[]) {
53
54
async_server::options options (async_handler);
54
55
async_server server_instance (ASYNC_SERVER_TEST_CONFIG);
55
56
56
- boost ::thread running_thread (
57
+ std ::thread running_thread (
57
58
boost::bind (&async_server::run, &server_instance));
58
- boost ::this_thread::sleep (ASYNC_SERVER_SLEEP_TIME);
59
+ std ::this_thread::sleep_for (ASYNC_SERVER_SLEEP_TIME);
59
60
60
- boost ::thread stopping_thread (
61
+ std ::thread stopping_thread (
61
62
boost::bind (&async_server::stop, &server_instance));
62
- boost ::this_thread::sleep (ASYNC_SERVER_SLEEP_TIME);
63
+ std ::this_thread::sleep_for (ASYNC_SERVER_SLEEP_TIME);
63
64
64
65
stopping_thread.join ();
65
66
running_thread.join ();
@@ -71,21 +72,21 @@ int main(int, char*[]) {
71
72
async_server::options options (async_handler);
72
73
async_server server_instance (ASYNC_SERVER_TEST_CONFIG);
73
74
74
- boost ::thread running_thread (
75
+ std ::thread running_thread (
75
76
boost::bind (&async_server::run, &server_instance));
76
- boost ::this_thread::sleep (ASYNC_SERVER_SLEEP_TIME);
77
+ std ::this_thread::sleep_for (ASYNC_SERVER_SLEEP_TIME);
77
78
78
- boost ::thread stopping_thread (
79
+ std ::thread stopping_thread (
79
80
boost::bind (&async_server::stop, &server_instance));
80
- boost ::this_thread::sleep (ASYNC_SERVER_SLEEP_TIME);
81
+ std ::this_thread::sleep_for (ASYNC_SERVER_SLEEP_TIME);
81
82
82
- boost ::thread second_running_thread (
83
+ std ::thread second_running_thread (
83
84
boost::bind (&async_server::run, &server_instance));
84
- boost ::this_thread::sleep (ASYNC_SERVER_SLEEP_TIME);
85
+ std ::this_thread::sleep_for (ASYNC_SERVER_SLEEP_TIME);
85
86
86
- boost ::thread second_stopping_thread (
87
+ std ::thread second_stopping_thread (
87
88
boost::bind (&async_server::stop, &server_instance));
88
- boost ::this_thread::sleep (ASYNC_SERVER_SLEEP_TIME);
89
+ std ::this_thread::sleep_for (ASYNC_SERVER_SLEEP_TIME);
89
90
90
91
stopping_thread.join ();
91
92
running_thread.join ();
@@ -99,17 +100,17 @@ int main(int, char*[]) {
99
100
async_server::options options (async_handler);
100
101
async_server server_instance (ASYNC_SERVER_TEST_CONFIG);
101
102
102
- boost ::thread running_thread (
103
+ std ::thread running_thread (
103
104
boost::bind (&async_server::run, &server_instance));
104
- boost ::this_thread::sleep (ASYNC_SERVER_SLEEP_TIME);
105
+ std ::this_thread::sleep_for (ASYNC_SERVER_SLEEP_TIME);
105
106
106
- boost ::thread second_running_thread (
107
+ std ::thread second_running_thread (
107
108
boost::bind (&async_server::run, &server_instance));
108
- boost ::this_thread::sleep (ASYNC_SERVER_SLEEP_TIME);
109
+ std ::this_thread::sleep_for (ASYNC_SERVER_SLEEP_TIME);
109
110
110
- boost ::thread stopping_thread (
111
+ std ::thread stopping_thread (
111
112
boost::bind (&async_server::stop, &server_instance));
112
- boost ::this_thread::sleep (ASYNC_SERVER_SLEEP_TIME);
113
+ std ::this_thread::sleep_for (ASYNC_SERVER_SLEEP_TIME);
113
114
114
115
stopping_thread.join ();
115
116
running_thread.join ();
@@ -122,17 +123,17 @@ int main(int, char*[]) {
122
123
async_server::options options (async_handler);
123
124
async_server server_instance (ASYNC_SERVER_TEST_CONFIG);
124
125
125
- boost ::thread running_thread (
126
+ std ::thread running_thread (
126
127
boost::bind (&async_server::run, &server_instance));
127
- boost ::this_thread::sleep (ASYNC_SERVER_SLEEP_TIME);
128
+ std ::this_thread::sleep_for (ASYNC_SERVER_SLEEP_TIME);
128
129
129
- boost ::thread stopping_thread (
130
+ std ::thread stopping_thread (
130
131
boost::bind (&async_server::stop, &server_instance));
131
- boost ::this_thread::sleep (ASYNC_SERVER_SLEEP_TIME);
132
+ std ::this_thread::sleep_for (ASYNC_SERVER_SLEEP_TIME);
132
133
133
- boost ::thread second_stopping_thread (
134
+ std ::thread second_stopping_thread (
134
135
boost::bind (&async_server::stop, &server_instance));
135
- boost ::this_thread::sleep (ASYNC_SERVER_SLEEP_TIME);
136
+ std ::this_thread::sleep_for (ASYNC_SERVER_SLEEP_TIME);
136
137
137
138
stopping_thread.join ();
138
139
second_stopping_thread.join ();
0 commit comments