diff options
author | Andreas Gampe <agampe@google.com> | 2016-11-16 13:58:05 -0800 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2016-11-17 08:33:16 -0800 |
commit | 6f3a70f316f2f3dcde5b3bde5fb258c556c46da6 (patch) | |
tree | e44245379077f57dee20b8576fa96c3d4c31704a /runtime/thread_pool.h | |
parent | 85347bd18d47066ea9a214d29cec994472ad18ca (diff) | |
download | art-6f3a70f316f2f3dcde5b3bde5fb258c556c46da6.tar.gz art-6f3a70f316f2f3dcde5b3bde5fb258c556c46da6.tar.bz2 art-6f3a70f316f2f3dcde5b3bde5fb258c556c46da6.zip |
ART: Change ThreadPool::Wait behavior
When a pool is in the stopped state, Wait() will not wait for all
tasks to complete.
Bug: 31385354
Test: m test-art-host-gtest-thread_pool_test
Change-Id: Id0144b685ee2fddf1a1c2c2ca334251130121033
Diffstat (limited to 'runtime/thread_pool.h')
-rw-r--r-- | runtime/thread_pool.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/runtime/thread_pool.h b/runtime/thread_pool.h index b6c6f02db8..2ff33a6053 100644 --- a/runtime/thread_pool.h +++ b/runtime/thread_pool.h @@ -100,7 +100,8 @@ class ThreadPool { ThreadPool(const char* name, size_t num_threads); virtual ~ThreadPool(); - // Wait for all tasks currently on queue to get completed. + // Wait for all tasks currently on queue to get completed. If the pool has been stopped, only + // wait till all already running tasks are done. void Wait(Thread* self, bool do_work, bool may_hold_locks) REQUIRES(!task_queue_lock_); size_t GetTaskCount(Thread* self) REQUIRES(!task_queue_lock_); @@ -130,6 +131,10 @@ class ThreadPool { return shutting_down_; } + bool HasOutstandingTasks() const REQUIRES(task_queue_lock_) { + return started_ && !tasks_.empty(); + } + const std::string name_; Mutex task_queue_lock_; ConditionVariable task_queue_condition_ GUARDED_BY(task_queue_lock_); |