pw_thread_threadx: Keep walking tasks on error
Changes behavior of the thread iterator to continue iteration over all
threads when an error is encountered.
Change-Id: I6ef8a0565165c0720f2c47d6982ff0031e33757f
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/53661
Commit-Queue: Armando Montanez <amontanez@google.com>
Pigweed-Auto-Submit: Armando Montanez <amontanez@google.com>
Reviewed-by: Ewout van Bekkum <ewout@google.com>
diff --git a/pw_thread_threadx/util.cc b/pw_thread_threadx/util.cc
index 0d9c5e5..078a51a 100644
--- a/pw_thread_threadx/util.cc
+++ b/pw_thread_threadx/util.cc
@@ -15,7 +15,6 @@
#include "pw_function/function.h"
#include "pw_status/status.h"
-#include "pw_status/try.h"
#include "tx_api.h"
#include "tx_thread.h"
@@ -24,11 +23,14 @@
namespace internal {
// Iterates through all threads that haven't been deleted, calling the provided
-// call
+// callback.
Status ForEachThread(const TX_THREAD& starting_thread, ThreadCallback& cb) {
const TX_THREAD* thread = &starting_thread;
do {
- PW_TRY(cb(*thread));
+ if (!cb(*thread)) {
+ // Early-terminate iteration if requested by the callback.
+ return Status::Aborted();
+ }
thread = thread->tx_thread_created_next;
} while (thread != &starting_thread);