Return whether should exit. Note even if return false, the task may be not empty because of remaining tasks before exit was set.
| 42 | // Return whether should exit. Note even if return false, the task may be not |
| 43 | // empty because of remaining tasks before exit was set. |
| 44 | bool ThreadPool::ThreadContext::GetPendingTask(TaskList* tasks) { |
| 45 | MutexLocker locker(&mutex); |
| 46 | free_tasks.splice(*tasks); |
| 47 | while (pending_tasks.empty() && !exit) { |
| 48 | cond.Wait(); |
| 49 | } |
| 50 | tasks->splice(pending_tasks); |
| 51 | return !exit; |
| 52 | } |
| 53 | |
| 54 | ThreadPool::ThreadPool(int num_threads): |
| 55 | m_num_threads(0), m_num_busy_threads(0), m_exit_cond(&m_exit_lock), m_exit(false) { |
no test coverage detected