pw_thread_stl: Stub thread_iteration backend

Change-Id: If7d1782a6ab0a0c7bcb8264284a477da94630af7
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/108054
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Medha Kini <medhakini@google.com>
diff --git a/pw_system/stl_backends.gni b/pw_system/stl_backends.gni
index de2f0c2..06d901e 100644
--- a/pw_system/stl_backends.gni
+++ b/pw_system/stl_backends.gni
@@ -33,6 +33,7 @@
   pw_thread_ID_BACKEND = "$dir_pw_thread_stl:id"
   pw_thread_SLEEP_BACKEND = "$dir_pw_thread_stl:sleep"
   pw_thread_THREAD_BACKEND = "$dir_pw_thread_stl:thread"
+  pw_thread_THREAD_ITERATION_BACKEND = "$dir_pw_thread_stl:thread_iteration"
   pw_thread_YIELD_BACKEND = "$dir_pw_thread_stl:yield"
   pw_system_TARGET_HOOKS_BACKEND = "$dir_pw_system:stl_target_hooks"
 }
diff --git a/pw_thread/BUILD.bazel b/pw_thread/BUILD.bazel
index 51b9b2d..a55d6c7 100644
--- a/pw_thread/BUILD.bazel
+++ b/pw_thread/BUILD.bazel
@@ -71,15 +71,17 @@
         "public/pw_thread/thread_iteration.h",
     ],
     includes = ["public"],
+    deps = [
+        ":thread_info",
+        "//pw_function",
+        "//pw_status",
+    ],
 )
 
 pw_cc_library(
     name = "thread_iteration",
     deps = [
-        ":thread_info",
         ":thread_iteration_facade",
-        "//pw_function",
-        "//pw_status",
         "@pigweed_config//:pw_thread_thread_backend",
     ],
 )
diff --git a/pw_thread_stl/BUILD.bazel b/pw_thread_stl/BUILD.bazel
index 91837a0..b9a98b1 100644
--- a/pw_thread_stl/BUILD.bazel
+++ b/pw_thread_stl/BUILD.bazel
@@ -101,6 +101,18 @@
     ],
 )
 
+# This target provides a stub backend for pw::this_thread::thread_iteration.
+# Iterating over child threads isn't supported by STL, so this only exists
+# for portability reasons.
+pw_cc_library(
+    name = "thread_iteration",
+    srcs = ["thread_iteration.cc"],
+    deps = [
+        "//pw_status",
+        "//pw_thread:thread_iteration_facade",
+    ],
+)
+
 pw_cc_library(
     name = "test_threads",
     srcs = [
diff --git a/pw_thread_stl/BUILD.gn b/pw_thread_stl/BUILD.gn
index 0e4e6b6..c4d693c 100644
--- a/pw_thread_stl/BUILD.gn
+++ b/pw_thread_stl/BUILD.gn
@@ -105,6 +105,17 @@
   deps = [ "$dir_pw_thread:yield.facade" ]
 }
 
+# This target provides a stub backend for pw::this_thread::thread_iteration.
+# Iterating over child threads isn't supported by STL, so this only exists
+# for portability reasons.
+pw_source_set("thread_iteration") {
+  deps = [
+    "$dir_pw_thread:thread_iteration.facade",
+    dir_pw_status,
+  ]
+  sources = [ "thread_iteration.cc" ]
+}
+
 pw_test_group("tests") {
   tests = [ ":thread_backend_test" ]
 }
diff --git a/pw_thread_stl/thread_iteration.cc b/pw_thread_stl/thread_iteration.cc
new file mode 100644
index 0000000..034a88f
--- /dev/null
+++ b/pw_thread_stl/thread_iteration.cc
@@ -0,0 +1,27 @@
+// Copyright 2022 The Pigweed Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//     https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+#include "pw_thread/thread_iteration.h"
+
+#include "pw_status/status.h"
+
+namespace pw::thread {
+
+// Stub backend implementation for STL. Unable to provide real implementation
+// for thread iteration on STL targets.
+Status ForEachThread([[maybe_unused]] const pw::thread::ThreadCallback& cb) {
+  return Status::Unimplemented();
+}
+
+}  // namespace pw::thread