Commit 508bc20a authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

tpool - misc fixes

parent c27577a1
...@@ -742,17 +742,14 @@ void thread_pool_generic::submit_task(task* task) ...@@ -742,17 +742,14 @@ void thread_pool_generic::submit_task(task* task)
/* Notify thread pool that current thread is going to wait */ /* Notify thread pool that current thread is going to wait */
void thread_pool_generic::wait_begin() void thread_pool_generic::wait_begin()
{ {
if (!tls_worker_data || tls_worker_data->is_long_task() || tls_worker_data->is_waiting()) if (!tls_worker_data || tls_worker_data->is_long_task())
return; return;
std::unique_lock<std::mutex> lk(m_mtx); std::unique_lock<std::mutex> lk(m_mtx);
tls_worker_data->m_state |= worker_data::WAITING; tls_worker_data->m_state |= worker_data::WAITING;
m_waiting_task_count++; m_waiting_task_count++;
/* Maintain concurrency */ /* Maintain concurrency */
if (m_task_queue.empty()) maybe_wake_or_create_thread();
return;
if (m_active_threads.size() - m_long_tasks_count - m_waiting_task_count < m_concurrency)
maybe_wake_or_create_thread();
} }
......
#include <tpool.h> #include <tpool.h>
namespace tpool
{
static thread_local tpool::thread_pool* tls_thread_pool; static thread_local tpool::thread_pool* tls_thread_pool;
extern "C" void set_tls_pool(tpool::thread_pool* pool) extern "C" void set_tls_pool(tpool::thread_pool* pool)
...@@ -18,4 +20,6 @@ extern "C" void tpool_wait_end() ...@@ -18,4 +20,6 @@ extern "C" void tpool_wait_end()
{ {
if (tls_thread_pool) if (tls_thread_pool)
tls_thread_pool->wait_end(); tls_thread_pool->wait_end();
} }
\ No newline at end of file
}
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