From 66a3d727cd8281911f9042cf9754e89b83bd3ce0 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 31 Mar 2022 21:50:27 +0200 Subject: [PATCH] Process rt-tasks (resample ports) in parallel (again). This was changed to single-thread execution in in bd229936ec2cb30fe3360f2d83ffc7197fd6fb97 and likely accidentally committed. --- libs/ardour/rt_tasklist.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libs/ardour/rt_tasklist.cc b/libs/ardour/rt_tasklist.cc index 18fcad8e3f..0b8841522f 100644 --- a/libs/ardour/rt_tasklist.cc +++ b/libs/ardour/rt_tasklist.cc @@ -144,29 +144,37 @@ void RTTaskList::process (TaskList const& tl) { Glib::Threads::Mutex::Lock pm (_process_mutex); + +#ifndef NDEBUG + /* must not be called while processing is already running */ Glib::Threads::Mutex::Lock tm (_tasklist_mutex, Glib::Threads::NOT_LOCK); - tm.acquire (); - _tasklist = tl; + assert (_tasklist.empty ()); tm.release (); +#endif + _tasklist = tl; process_tasklist (); +#ifndef NDEBUG + /* ensure that all tasks are processed, and threads are in wait state */ tm.acquire (); - _tasklist.clear (); + assert (_tasklist.empty ()); tm.release (); +#endif } void RTTaskList::process_tasklist () { -// if (0 == g_atomic_int_get (&_threads_active) || _threads.size () == 0) { + if (0 == g_atomic_int_get (&_threads_active) || _threads.size () == 0) { for (TaskList::iterator i = _tasklist.begin (); i != _tasklist.end(); ++i) { (*i)(); } + _tasklist.clear (); return; -// } + } uint32_t nt = std::min (_threads.size (), _tasklist.size ());