@@ -179,7 +179,7 @@ class Activity : public Orphanable {
179179 // locked
180180 // - back up that assertation with a runtime check in debug builds (it's
181181 // prohibitively expensive in non-debug builds)
182- static Activity* current () { return g_current_activity_ ; }
182+ static Activity* current () { return * GetCurrentActivity () ; }
183183
184184 // Produce an activity-owning Waker. The produced waker will keep the activity
185185 // alive until it's awoken or dropped.
@@ -196,17 +196,17 @@ class Activity : public Orphanable {
196196 protected:
197197 // Check if this activity is the current activity executing on the current
198198 // thread.
199- bool is_current () const { return this == g_current_activity_ ; }
199+ bool is_current () const { return this == * GetCurrentActivity () ; }
200200 // Check if there is an activity executing on the current thread.
201- static bool have_current () { return g_current_activity_ != nullptr ; }
201+ static bool have_current () { return * GetCurrentActivity () != nullptr ; }
202202 // Set the current activity at construction, clean it up at destruction.
203203 class ScopedActivity {
204204 public:
205205 explicit ScopedActivity (Activity* activity)
206- : prior_activity_(g_current_activity_ ) {
207- g_current_activity_ = activity;
206+ : prior_activity_(* GetCurrentActivity () ) {
207+ * GetCurrentActivity () = activity;
208208 }
209- ~ScopedActivity () { g_current_activity_ = prior_activity_; }
209+ ~ScopedActivity () { * GetCurrentActivity () = prior_activity_; }
210210 ScopedActivity (const ScopedActivity&) = delete;
211211 ScopedActivity& operator =(const ScopedActivity&) = delete;
212212
@@ -217,6 +217,7 @@ class Activity : public Orphanable {
217217 private:
218218 // Set during RunLoop to the Activity that's executing.
219219 // Being set implies that mu_ is held.
220+ static Activity** GetCurrentActivity ();
220221 static thread_local Activity* g_current_activity_;
221222};
222223
0 commit comments