Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
fix: Task dispatcher handle busy and other issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gaowanlu committed Aug 18, 2023
1 parent 055c922 commit 34f9bbe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
12 changes: 1 addition & 11 deletions src/thread/task_dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,7 @@ namespace tubekit
{
singleton<logger>::instance()->debug(__FILE__, __LINE__, "task dispatcher handle task");
thread_pool<THREAD, TASK> *pool = singleton<thread_pool<THREAD, TASK>>::instance();
if (pool->get_idle_thread_numbers() > 0)
{
pool->assign(m_task);
}
else
{
m_mutex.lock();
m_tasks.push_front(m_task); // If there are no free threads, they are put into the list first
m_mutex.unlock();
singleton<logger>::instance()->debug(__FILE__, __LINE__, "all threads are busy");
}
pool->assign(m_task);
}

template <typename THREAD, typename TASK>
Expand Down
2 changes: 2 additions & 0 deletions src/thread/thread_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ namespace tubekit
*/
void assign(TASK *m_task);

void wait_exist_idle();

private:
/**
* @brief number of threads in pool
Expand Down

0 comments on commit 34f9bbe

Please sign in to comment.