|
|
@ -311,20 +311,21 @@ void task_thread_pool::start(int32_t prio, uint32_t mask)
|
|
|
|
void task_thread_pool::stop()
|
|
|
|
void task_thread_pool::stop()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::unique_lock<std::mutex> lock(queue_mutex);
|
|
|
|
std::unique_lock<std::mutex> lock(queue_mutex);
|
|
|
|
running = false;
|
|
|
|
if (running) {
|
|
|
|
nof_workers_running = 0;
|
|
|
|
running = false;
|
|
|
|
// next worker that is still running
|
|
|
|
bool workers_running = false;
|
|
|
|
for (worker_t& w : workers) {
|
|
|
|
for (worker_t& w : workers) {
|
|
|
|
if (w.is_running()) {
|
|
|
|
if (w.is_running()) {
|
|
|
|
nof_workers_running++;
|
|
|
|
workers_running = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nof_workers_running > 0) {
|
|
|
|
|
|
|
|
lock.unlock();
|
|
|
|
lock.unlock();
|
|
|
|
cv_empty.notify_all();
|
|
|
|
if (workers_running) {
|
|
|
|
lock.lock();
|
|
|
|
cv_empty.notify_all();
|
|
|
|
while (nof_workers_running > 0) {
|
|
|
|
}
|
|
|
|
cv_exit.wait(lock);
|
|
|
|
for (worker_t& w : workers) {
|
|
|
|
|
|
|
|
w.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -360,8 +361,14 @@ task_thread_pool::worker_t::worker_t(srslte::task_thread_pool* parent_, uint32_t
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void task_thread_pool::worker_t::stop()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
wait_thread_finish();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void task_thread_pool::worker_t::setup(int32_t prio, uint32_t mask)
|
|
|
|
void task_thread_pool::worker_t::setup(int32_t prio, uint32_t mask)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
running = true;
|
|
|
|
if (mask == 255) {
|
|
|
|
if (mask == 255) {
|
|
|
|
start(prio);
|
|
|
|
start(prio);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -387,8 +394,6 @@ bool task_thread_pool::worker_t::wait_task(task_t* task)
|
|
|
|
|
|
|
|
|
|
|
|
void task_thread_pool::worker_t::run_thread()
|
|
|
|
void task_thread_pool::worker_t::run_thread()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
running = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// main loop
|
|
|
|
// main loop
|
|
|
|
task_t task;
|
|
|
|
task_t task;
|
|
|
|
while (wait_task(&task)) {
|
|
|
|
while (wait_task(&task)) {
|
|
|
@ -398,11 +403,6 @@ void task_thread_pool::worker_t::run_thread()
|
|
|
|
// on exit, notify pool class
|
|
|
|
// on exit, notify pool class
|
|
|
|
std::unique_lock<std::mutex> lock(parent->queue_mutex);
|
|
|
|
std::unique_lock<std::mutex> lock(parent->queue_mutex);
|
|
|
|
running = false;
|
|
|
|
running = false;
|
|
|
|
parent->nof_workers_running--;
|
|
|
|
|
|
|
|
if (parent->nof_workers_running == 0) {
|
|
|
|
|
|
|
|
lock.unlock();
|
|
|
|
|
|
|
|
parent->cv_exit.notify_one();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace srslte
|
|
|
|
} // namespace srslte
|
|
|
|