diff options
Diffstat (limited to 'runtime/thread_pool.h')
-rw-r--r-- | runtime/thread_pool.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/runtime/thread_pool.h b/runtime/thread_pool.h index b6c6f02db8..739ac66ec9 100644 --- a/runtime/thread_pool.h +++ b/runtime/thread_pool.h @@ -77,6 +77,7 @@ class ThreadPoolWorker { DISALLOW_COPY_AND_ASSIGN(ThreadPoolWorker); }; +// Note that thread pool workers will set Thread#setCanCallIntoJava to false. class ThreadPool { public: // Returns the number of threads in the thread pool. @@ -97,10 +98,16 @@ class ThreadPool { // Remove all tasks in the queue. void RemoveAllTasks(Thread* self) REQUIRES(!task_queue_lock_); - ThreadPool(const char* name, size_t num_threads); + // Create a named thread pool with the given number of threads. + // + // If create_peers is true, all worker threads will have a Java peer object. Note that if the + // pool is asked to do work on the current thread (see Wait), a peer may not be available. Wait + // will conservatively abort if create_peers and do_work are true. + ThreadPool(const char* name, size_t num_threads, bool create_peers = false); virtual ~ThreadPool(); // Wait for all tasks currently on queue to get completed. + // When the pool was created with peers for workers, do_work must not be true (see ThreadPool()). void Wait(Thread* self, bool do_work, bool may_hold_locks) REQUIRES(!task_queue_lock_); size_t GetTaskCount(Thread* self) REQUIRES(!task_queue_lock_); @@ -146,6 +153,7 @@ class ThreadPool { uint64_t total_wait_time_; Barrier creation_barier_; size_t max_active_workers_ GUARDED_BY(task_queue_lock_); + const bool create_peers_; private: friend class ThreadPoolWorker; |