Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 33 additions & 8 deletions gloop/thread/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -70,7 +67,6 @@ POSIX_PORT_HEADERS = [
"thread.h",
"threadlocal.h",
"threadpool.h",
"thread_options.h",
"timedcall.h",
"wait_queue_thread.h",
]
Expand Down Expand Up @@ -220,28 +216,55 @@ 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({
"//conditions:default": [
"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",
"timedcall.cc",
"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",
Expand All @@ -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",
Expand Down
1 change: 0 additions & 1 deletion gloop/thread/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include <unistd.h>
#endif

#define THREAD_HAVE_CPU_SUBCONTAINERS 0
#define THREAD_HAVE_THREAD_CONTROL 1

// THREAD_HAVE_THREAD_CLASS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}

Expand Down
4 changes: 2 additions & 2 deletions gloop/thread/thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion gloop/thread/thread_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading