Replace boost thread with std thread; update rest book example; move soap tutorials to wiki.
This commit is contained in:
@@ -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,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
|
||||
|
||||
Reference in New Issue
Block a user