From da07e7a05122225654f5875ec396a91f704b10e7 Mon Sep 17 00:00:00 2001 From: Gloop Team Date: Thu, 13 Aug 2026 05:34:52 -0700 Subject: [PATCH] Automated rollback of commit 54559630505327a8e2ca3a9f732ba601735a02f6. PiperOrigin-RevId: 964026475 --- gloop/thread/BUILD | 41 +++++++++++++++---- gloop/thread/config.h | 1 - ...bcontainer.cc => cpu_subcontainer_stub.cc} | 6 --- gloop/thread/thread.cc | 4 +- gloop/thread/thread_options.h | 5 ++- 5 files changed, 39 insertions(+), 18 deletions(-) rename gloop/thread/{port/cpu_subcontainer.cc => cpu_subcontainer_stub.cc} (90%) diff --git a/gloop/thread/BUILD b/gloop/thread/BUILD index 34cdc291..dd3887db 100644 --- a/gloop/thread/BUILD +++ b/gloop/thread/BUILD @@ -46,15 +46,12 @@ POSIX_PORT_DEPS = [ POSIX_PORT_SOURCES = [ "add_after_helper.cc", - "cpu_subcontainer.h", # Stubbed out, private. "executor.cc", "logger.h", "pcqueue.h", # private. - "port/cpu_subcontainer.cc", "python_stack_size.h", "timedcall.cc", "thread.cc", - "thread_options.cc", "threadlocal.cc", "threadlocal-internal.h", "threadpool.cc", @@ -70,7 +67,6 @@ POSIX_PORT_HEADERS = [ "thread.h", "threadlocal.h", "threadpool.h", - "thread_options.h", "timedcall.h", "wait_queue_thread.h", ] @@ -220,6 +216,33 @@ cc_library( ], ) +cc_library( + name = "thread_options", + srcs = ["thread_options.cc"], + hdrs = ["thread_options.h"], + deps = [ + "//gloop:enforce_gloop_support", + "@abseil-cpp//absl/flags:flag", + ], +) + +cc_library( + name = "cpu_subcontainer_stub", + srcs = ["cpu_subcontainer_stub.cc"], + hdrs = ["cpu_subcontainer.h"], + visibility = ["//visibility:private"], + deps = ["//gloop:enforce_gloop_support"], +) + +cc_library( + name = "cpu_subcontainer", + hdrs = ["cpu_subcontainer.h"], + deps = [ + ":cpu_subcontainer_stub", + "//gloop:enforce_gloop_support", + ], +) + cc_library( name = "thread", srcs = select({ @@ -227,11 +250,9 @@ cc_library( "add_after_helper.cc", "executor.cc", "logger.cc", - "port/cpu_subcontainer.cc", "stack_reclaimer.cc", "stack_reclaimer.h", "thread.cc", - "thread_options.cc", "threadlocal.cc", "threadlocal-internal.h", "threadpool.cc", @@ -239,9 +260,11 @@ cc_library( "watchdog.cc", ], }), - hdrs = select({ + hdrs = [ + "cpu_subcontainer.h", + "thread_options.h", + ] + select({ "//conditions:default": POSIX_PORT_HEADERS + [ - "cpu_subcontainer.h", "logger.h", "pcqueue.h", "watchdog.h", @@ -252,12 +275,14 @@ cc_library( }), deps = [ ":config", + ":cpu_subcontainer", ":exit_timeout_seconds", ":os_semaphore", ":prioritized_wait_queue", ":python_stack_size", ":sync_queue", ":thread-internal", + ":thread_options", ":wait_queue", ":wait_state", "//gloop:enforce_gloop_support", diff --git a/gloop/thread/config.h b/gloop/thread/config.h index d5cac088..4a3f78b6 100644 --- a/gloop/thread/config.h +++ b/gloop/thread/config.h @@ -38,7 +38,6 @@ #include #endif -#define THREAD_HAVE_CPU_SUBCONTAINERS 0 #define THREAD_HAVE_THREAD_CONTROL 1 // THREAD_HAVE_THREAD_CLASS: diff --git a/gloop/thread/port/cpu_subcontainer.cc b/gloop/thread/cpu_subcontainer_stub.cc similarity index 90% rename from gloop/thread/port/cpu_subcontainer.cc rename to gloop/thread/cpu_subcontainer_stub.cc index b14a79f5..b6ddaf36 100644 --- a/gloop/thread/port/cpu_subcontainer.cc +++ b/gloop/thread/cpu_subcontainer_stub.cc @@ -22,12 +22,6 @@ #include "gloop/thread/cpu_subcontainer.h" -#include "gloop/thread/config.h" - -#if THREAD_HAVE_CPU_SUBCONTAINERS -#error Feature macros and BUILD file are out of sync. -#endif - thread::CpuSubContainer::CpuSubContainer(const std::string& path) : path_(path) {} diff --git a/gloop/thread/thread.cc b/gloop/thread/thread.cc index e0d8d1ae..956d07c0 100644 --- a/gloop/thread/thread.cc +++ b/gloop/thread/thread.cc @@ -659,7 +659,7 @@ void Thread::Start(absl::SourceLocation loc) { #if !defined(__Fuchsia__) pthread_attr_setschedpolicy(&attr, SCHED_FIFO); #endif - if (options_.sched_priority() < 0) { + if (options_.get_sched_priority() < 0) { sched_param.sched_priority = sched_get_priority_max(SCHED_FIFO) - 1; } else { #ifdef THREAD_HAVE_IOPRIORITY @@ -677,7 +677,7 @@ void Thread::Start(absl::SourceLocation loc) { // is set. pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); #endif - sched_param.sched_priority = options_.sched_priority(); + sched_param.sched_priority = options_.get_sched_priority(); } pthread_attr_setschedparam(&attr, &sched_param); break; diff --git a/gloop/thread/thread_options.h b/gloop/thread/thread_options.h index 1a5baba3..bcf017f1 100644 --- a/gloop/thread/thread_options.h +++ b/gloop/thread/thread_options.h @@ -148,7 +148,10 @@ class Options { return *this; } - int sched_priority() const { return sched_priority_; } + /** Return the scheduling priority. This is named differently because some + * targets define a macro named `sched_priority` in global scope. + */ + int get_sched_priority() const { return sched_priority_; } // // CAUTION: The following methods are not for general use