aboutsummaryrefslogtreecommitdiffstats
path: root/include/http_server.h
diff options
context:
space:
mode:
authorJaeseung Ha <ipknhama@gmail.com>2016-09-06 09:39:13 +0900
committerJaeseung Ha <ipknhama@gmail.com>2016-09-06 09:39:13 +0900
commit800d31411d8187b2df7b58e4d025612bc7cbb048 (patch)
tree991f38d3e1f25499cdbba9348f8ee1e8cdc39eac /include/http_server.h
parent3b389460921e9b0869f81cc0c5b6cc98c3a3ee01 (diff)
downloadcrow-800d31411d8187b2df7b58e4d025612bc7cbb048.tar.gz
crow-800d31411d8187b2df7b58e4d025612bc7cbb048.zip
Fix issue #89
Diffstat (limited to 'include/http_server.h')
-rw-r--r--include/http_server.h11
1 files changed, 5 insertions, 6 deletions
diff --git a/include/http_server.h b/include/http_server.h
index addbbc1..86943ee 100644
--- a/include/http_server.h
+++ b/include/http_server.h
@@ -48,9 +48,10 @@ namespace crow
timer_queue_pool_.resize(concurrency_);
std::vector<std::future<void>> v;
+ std::atomic<int> init_count(0);
for(uint16_t i = 0; i < concurrency_; i ++)
v.push_back(
- std::async(std::launch::async, [this, i]{
+ std::async(std::launch::async, [this, i, &init_count]{
// thread local date string get function
auto last = std::chrono::steady_clock::now();
@@ -99,6 +100,7 @@ namespace crow
};
timer.async_wait(handler);
+ init_count ++;
try
{
io_service_pool_[i]->run();
@@ -114,11 +116,8 @@ namespace crow
stop();
});
- for (int i = 0; i < concurrency_; i++)
- {
- while (timer_queue_pool_[i] == nullptr)
- std::this_thread::yield();
- }
+ while(concurrency_ != init_count)
+ std::this_thread::yield();
do_accept();