File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 1212#include " vm/allocation.h"
1313#include " vm/globals.h"
1414#include " vm/intrusive_dlist.h"
15+ #include " vm/lockers.h"
1516#include " vm/os_thread.h"
1617
1718namespace dart {
@@ -76,10 +77,16 @@ class ThreadPool {
7677 static void RequestShutdown (ThreadPool* pool,
7778 std::function<void (void )>&& shutdown_complete);
7879
79- // Exposed for unit test in thread_pool_test.cc
80- uint64_t workers_started () const { return count_idle_ + count_running_; }
81- // Exposed for unit test in thread_pool_test.cc
82- bool has_pending_dead_worker () const { return last_dead_worker_ != nullptr ; }
80+ #if defined(TESTING)
81+ uint64_t workers_started () const {
82+ MutexLocker ml (&pool_mutex_);
83+ return count_idle_ + count_running_;
84+ }
85+ bool has_pending_dead_worker () const {
86+ MutexLocker ml (&pool_mutex_);
87+ return last_dead_worker_ != nullptr ;
88+ }
89+ #endif
8390
8491 protected:
8592 class Worker : public IntrusiveDListEntry <Worker> {
@@ -149,7 +156,7 @@ class ThreadPool {
149156
150157 void DeleteLastDeadWorker ();
151158
152- Mutex pool_mutex_;
159+ mutable Mutex pool_mutex_;
153160 bool shutting_down_ = false ;
154161 uint64_t count_running_ = 0 ;
155162 uint64_t count_idle_ = 0 ;
You can’t perform that action at this time.
0 commit comments