Commit cc998bac authored by Dominik Charousset's avatar Dominik Charousset

reduce latency by changing worker strategy

parent c5800cda
...@@ -73,7 +73,7 @@ struct thread_pool_scheduler::worker { ...@@ -73,7 +73,7 @@ struct thread_pool_scheduler::worker {
job_ptr aggressive_polling() { job_ptr aggressive_polling() {
job_ptr result = nullptr; job_ptr result = nullptr;
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 100; ++i) {
result = m_job_queue->try_pop(); result = m_job_queue->try_pop();
if (result) { if (result) {
return result; return result;
...@@ -85,12 +85,13 @@ struct thread_pool_scheduler::worker { ...@@ -85,12 +85,13 @@ struct thread_pool_scheduler::worker {
job_ptr less_aggressive_polling() { job_ptr less_aggressive_polling() {
job_ptr result = nullptr; job_ptr result = nullptr;
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 550; ++i) {
result = m_job_queue->try_pop(); result = m_job_queue->try_pop();
if (result) { if (result) {
return result; return result;
} }
std::this_thread::sleep_for(std::chrono::milliseconds(1)); //std::this_thread::sleep_for(std::chrono::milliseconds(1));
std::this_thread::sleep_for(std::chrono::microseconds(50));
} }
return result; return result;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment