1+ #include < thread>
2+ #include < chrono>
13#include < boost/network/include/http/server.hpp>
2- #include < boost/thread.hpp>
34
45namespace http = boost::network::http;
56namespace util = boost::network::utils;
@@ -23,7 +24,7 @@ int main(int, char*[]) {
2324#define ASYNC_SERVER_TEST_CONFIG \
2425 options.address (" 127.0.0.1" ).port (" 8007" ).reuse_address (true )
2526
26- #define ASYNC_SERVER_SLEEP_TIME boost::posix_time ::milliseconds (100 )
27+ #define ASYNC_SERVER_SLEEP_TIME std::chrono ::milliseconds (100 )
2728
2829// stop from main thread
2930 {
@@ -39,9 +40,9 @@ int main(int, char*[]) {
3940 async_server::optionsoptions (async_handler);
4041 async_serverserver_instance (ASYNC_SERVER_TEST_CONFIG);
4142
42- boost ::threadrunning_thread (
43+ std ::threadrunning_thread (
4344boost::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);
4546
4647 server_instance.stop ();
4748 running_thread.join ();
@@ -53,13 +54,13 @@ int main(int, char*[]) {
5354 async_server::optionsoptions (async_handler);
5455 async_serverserver_instance (ASYNC_SERVER_TEST_CONFIG);
5556
56- boost ::threadrunning_thread (
57+ std ::threadrunning_thread (
5758boost::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);
5960
60- boost ::threadstopping_thread (
61+ std ::threadstopping_thread (
6162boost::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);
6364
6465 stopping_thread.join ();
6566 running_thread.join ();
@@ -71,21 +72,21 @@ int main(int, char*[]) {
7172 async_server::optionsoptions (async_handler);
7273 async_serverserver_instance (ASYNC_SERVER_TEST_CONFIG);
7374
74- boost ::threadrunning_thread (
75+ std ::threadrunning_thread (
7576boost::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);
7778
78- boost ::threadstopping_thread (
79+ std ::threadstopping_thread (
7980boost::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);
8182
82- boost ::threadsecond_running_thread (
83+ std ::threadsecond_running_thread (
8384boost::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);
8586
86- boost ::threadsecond_stopping_thread (
87+ std ::threadsecond_stopping_thread (
8788boost::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);
8990
9091 stopping_thread.join ();
9192 running_thread.join ();
@@ -99,17 +100,17 @@ int main(int, char*[]) {
99100 async_server::optionsoptions (async_handler);
100101 async_serverserver_instance (ASYNC_SERVER_TEST_CONFIG);
101102
102- boost ::threadrunning_thread (
103+ std ::threadrunning_thread (
103104boost::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);
105106
106- boost ::threadsecond_running_thread (
107+ std ::threadsecond_running_thread (
107108boost::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);
109110
110- boost ::threadstopping_thread (
111+ std ::threadstopping_thread (
111112boost::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);
113114
114115 stopping_thread.join ();
115116 running_thread.join ();
@@ -122,17 +123,17 @@ int main(int, char*[]) {
122123 async_server::optionsoptions (async_handler);
123124 async_serverserver_instance (ASYNC_SERVER_TEST_CONFIG);
124125
125- boost ::threadrunning_thread (
126+ std ::threadrunning_thread (
126127boost::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);
128129
129- boost ::threadstopping_thread (
130+ std ::threadstopping_thread (
130131boost::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);
132133
133- boost ::threadsecond_stopping_thread (
134+ std ::threadsecond_stopping_thread (
134135boost::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);
136137
137138 stopping_thread.join ();
138139 second_stopping_thread.join ();