|
|
@ -82,7 +82,8 @@ void thread_pool::init_worker(uint32_t id, worker* obj, uint32_t prio, uint32_t
|
|
|
|
|
|
|
|
|
|
|
|
void thread_pool::stop()
|
|
|
|
void thread_pool::stop()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mutex_queue.lock();
|
|
|
|
{
|
|
|
|
|
|
|
|
std::lock_guard<std::mutex> lock(mutex_queue);
|
|
|
|
|
|
|
|
|
|
|
|
/* Stop any thread waiting for available worker */
|
|
|
|
/* Stop any thread waiting for available worker */
|
|
|
|
running = false;
|
|
|
|
running = false;
|
|
|
@ -96,7 +97,7 @@ void thread_pool::stop()
|
|
|
|
cvar_queue.notify_all();
|
|
|
|
cvar_queue.notify_all();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mutex_queue.unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < nof_workers; i++) {
|
|
|
|
for (uint32_t i = 0; i < nof_workers; i++) {
|
|
|
|
debug_thread("stop(): waiting %d\n", i);
|
|
|
|
debug_thread("stop(): waiting %d\n", i);
|
|
|
@ -136,6 +137,12 @@ void thread_pool::worker::finished()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool thread_pool::worker::is_stopped() const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::lock_guard<std::mutex> lock(my_parent->mutex_queue);
|
|
|
|
|
|
|
|
return my_parent->status[my_id] == STOP;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool thread_pool::find_finished_worker(uint32_t tti, uint32_t* id)
|
|
|
|
bool thread_pool::find_finished_worker(uint32_t tti, uint32_t* id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < nof_workers; i++) {
|
|
|
|
for (uint32_t i = 0; i < nof_workers; i++) {
|
|
|
|