pw_thread: adds thread creation

Adds a std::thread like API through a new pw_thread facade based
on the STL's std::thread API, however with more restricted function
entry routine format support and backend specific option support
to permit non-portable configuration of thread settings/parameters
including static context allocations.

In addition this provides an initial set of backends based on using
the STL's std::thread directly.

Change-Id: Ib8c3cbdc434044e204e67e58d861a40e4acec9b4
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/30920
Reviewed-by: Wyatt Hepler <hepler@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Ewout van Bekkum <ewout@google.com>
diff --git a/pw_thread/BUILD b/pw_thread/BUILD
index 4335978..073897c 100644
--- a/pw_thread/BUILD
+++ b/pw_thread/BUILD
@@ -25,6 +25,7 @@
 # TODO(pwbug/101): Need to add support for facades/backends to Bazel.
 PW_THREAD_ID_BACKEND = "//pw_thread_stl:id"
 PW_THREAD_SLEEP_BACKEND = "//pw_thread_stl:sleep"
+PW_THREAD_THREAD_BACKEND = "//pw_thread_stl:thread"
 PW_THREAD_YIELD_BACKEND = "//pw_thread_stl:yield"
 
 pw_cc_library(
@@ -85,6 +86,33 @@
 )
 
 pw_cc_library(
+    name = "thread_facade",
+    hdrs = [
+        "public/pw_thread/thread.h",
+    ],
+    includes = ["public"],
+    deps = [
+        ":id_facade",
+        PW_THREAD_THREAD_BACKEND + "_headers",
+    ],
+)
+
+pw_cc_library(
+    name = "thread",
+    deps = [
+        ":thread_facade",
+        PW_THREAD_THREAD_BACKEND + "_headers",
+    ],
+)
+
+pw_cc_library(
+    name = "thread_backend",
+    deps = [
+       PW_THREAD_THREAD_BACKEND,
+    ],
+)
+
+pw_cc_library(
     name = "yield_facade",
     hdrs = [
         "public/pw_thread/yield.h",
@@ -114,6 +142,32 @@
     ],
 )
 
+pw_cc_library(
+    name = "test_threads_header",
+    hdrs = [
+        "public/pw_thread/test_threads.h",
+    ],
+    deps = [
+        ":thread",
+    ],
+)
+
+# To instantiate this as a pw_cc_test, depend on this pw_cc_library and the
+# pw_cc_library which implements the backend for test_threads_header. See
+# //pw_thread:thread_backend_test as an example.
+pw_cc_library(
+    name = "thread_facade_test",
+    srcs = [
+        "thread_facade_test.cc",
+    ],
+    deps = [
+        ":thread",
+        ":id",
+        ":test_threads_header",
+        "//pw_unit_test",
+    ],
+)
+
 pw_cc_test(
     name = "id_facade_test",
     srcs = [