summaryrefslogtreecommitdiff
path: root/runtime/runtime.h
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2022-01-16 14:01:36 -0800
committerLinux Build Service Account <lnxbuild@localhost>2022-01-16 14:01:36 -0800
commit5806f26e603150889d7b7e044cd8fb685c832f4e (patch)
treee60b0a64a2b342e96f6b886ec3e2e453e494e567 /runtime/runtime.h
parentaa20688e701376b1a4cfffc6284721819806cb90 (diff)
parentf9da627a42193f596d33d799bf323fced18214c5 (diff)
Merge f9da627a42193f596d33d799bf323fced18214c5 on remote branch
Change-Id: Iaf48868208da271af8b4536f089c44bf4412cc9e
Diffstat (limited to 'runtime/runtime.h')
-rw-r--r--runtime/runtime.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/runtime/runtime.h b/runtime/runtime.h
index 68456cd37b..b2093a303c 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -222,7 +222,13 @@ class Runtime {
bool IsShuttingDown(Thread* self);
bool IsShuttingDownLocked() const REQUIRES(Locks::runtime_shutdown_lock_) {
- return shutting_down_;
+ return shutting_down_.load(std::memory_order_relaxed);
+ }
+ bool IsShuttingDownUnsafe() const {
+ return shutting_down_.load(std::memory_order_relaxed);
+ }
+ void SetShuttingDown() REQUIRES(Locks::runtime_shutdown_lock_) {
+ shutting_down_.store(true, std::memory_order_relaxed);
}
size_t NumberOfThreadsBeingBorn() const REQUIRES(Locks::runtime_shutdown_lock_) {
@@ -1190,8 +1196,10 @@ class Runtime {
// Waited upon until no threads are being born.
std::unique_ptr<ConditionVariable> shutdown_cond_ GUARDED_BY(Locks::runtime_shutdown_lock_);
- // Set when runtime shutdown is past the point that new threads may attach.
- bool shutting_down_ GUARDED_BY(Locks::runtime_shutdown_lock_);
+ // Set when runtime shutdown is past the point that new threads may attach. Usually
+ // GUARDED_BY(Locks::runtime_shutdown_lock_). But we need to check it in Abort without the
+ // lock, because we may already own it.
+ std::atomic<bool> shutting_down_;
// The runtime is starting to shutdown but is blocked waiting on shutdown_cond_.
bool shutting_down_started_ GUARDED_BY(Locks::runtime_shutdown_lock_);