Remove the forward declaration of base::scheduling::Schedulable from

thread_identity by using a void*, and fix callers to use
base::scheduling::Schedulable::GetBoundSchedulable().

PiperOrigin-RevId: 894096577
Change-Id: I2d4c822c60501e34cadcaac7fc434ef9adb222c3
This commit is contained in:
Derek Mauro
2026-04-03 08:50:05 -07:00
committed by Copybara-Service
parent 5c01794f79
commit 3eb0f0bd73
2 changed files with 7 additions and 19 deletions

View File

@@ -18,6 +18,8 @@
#ifndef ABSL_BASE_INTERNAL_LOW_LEVEL_SCHEDULING_H_
#define ABSL_BASE_INTERNAL_LOW_LEVEL_SCHEDULING_H_
#include <atomic>
#include "absl/base/internal/raw_logging.h"
#include "absl/base/internal/scheduling_mode.h"
#include "absl/base/internal/thread_identity.h"
@@ -103,15 +105,14 @@ class SchedulingGuard {
//------------------------------------------------------------------------------
inline bool SchedulingGuard::ReschedulingIsAllowed() {
ThreadIdentity* identity;
identity = CurrentThreadIdentityIfPresent();
ThreadIdentity* identity = CurrentThreadIdentityIfPresent();
if (identity != nullptr) {
ThreadIdentity::SchedulerState* state;
state = &identity->scheduler_state;
ThreadIdentity::SchedulerState* state = &identity->scheduler_state;
// For a thread to be eligible for re-scheduling it must have a bound
// schedulable (otherwise it's not cooperative) and not be within a
// SchedulerGuard region.
return state->get_bound_schedulable() != nullptr &&
return state->bound_schedulable.load(std::memory_order_relaxed) !=
nullptr &&
state->scheduling_disabled_depth.load(std::memory_order_relaxed) ==
0;
} else {

View File

@@ -34,14 +34,6 @@
#include "absl/base/internal/per_thread_tls.h"
#include "absl/base/optimization.h"
// Forward declare Gloop class for scheduling.
// TODO: b/495759467 - Remove this forward declaration.
namespace base {
namespace scheduling {
class Schedulable;
} // namespace scheduling
} // namespace base
namespace absl {
ABSL_NAMESPACE_BEGIN
@@ -155,7 +147,7 @@ struct ThreadIdentity {
PerThreadSynch per_thread_synch;
struct SchedulerState {
std::atomic<base::scheduling::Schedulable*> bound_schedulable{nullptr};
std::atomic<void*> bound_schedulable{nullptr};
// Storage space for a SpinLock, which is created through a placement new to
// break a dependency cycle.
uint32_t association_lock_word;
@@ -172,11 +164,6 @@ struct ThreadIdentity {
inline SpinLock* association_lock() {
return reinterpret_cast<SpinLock*>(&association_lock_word);
}
// TODO: b/495759467 - Migrate all callers.
inline base::scheduling::Schedulable* get_bound_schedulable() const {
return bound_schedulable.load(std::memory_order_relaxed);
}
} scheduler_state; // Private: Reserved for use in Gloop
// For worker threads that may not be doing any interesting user work, this