Replace boost thread with std thread; update rest book example; move soap tutorials to wiki.

This commit is contained in:
Adam Gu
2018-07-23 15:40:58 +08:00
parent 6475a3fd35
commit 33f2b84f8c
11 changed files with 64 additions and 446 deletions
+6 -2
View File
@@ -17,7 +17,7 @@ void HttpRequestHandler::Start(std::size_t count) {
assert(count > 0 && workers_.size() == 0);
for (std::size_t i = 0; i < count; ++i) {
workers_.create_thread(std::bind(&HttpRequestHandler::WorkerRoutine, this));
workers_.emplace_back(std::bind(&HttpRequestHandler::WorkerRoutine, this));
}
}
@@ -33,7 +33,11 @@ void HttpRequestHandler::Stop() {
// Enqueue a null connection to trigger the first worker to stop.
queue_.Push(HttpConnectionPtr());
workers_.join_all();
for (auto& worker : workers_) {
if (worker.joinable()) {
worker.join();
}
}
LOG_INFO("All workers have been stopped.");
}
+2 -3
View File
@@ -2,10 +2,9 @@
#define WEBCC_HTTP_REQUEST_HANDLER_H_
#include <list>
#include <thread>
#include <vector>
#include "boost/thread/thread.hpp"
#include "webcc/http_connection.h"
#include "webcc/queue.h"
#include "webcc/soap_service.h"
@@ -39,7 +38,7 @@ class HttpRequestHandler {
virtual void HandleConnection(HttpConnectionPtr connection) = 0;
Queue<HttpConnectionPtr> queue_;
boost::thread_group workers_;
std::vector<std::thread> workers_;
};
} // namespace webcc