153 "_active_workers: %u > _total_workers: %u", _active_workers, _total_workers);
154 assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers,
155 "Unless dynamic should use total workers");
156 return _active_workers;
157 }
158
159 void set_active_workers(uint v) {
160 assert(v <= _total_workers,
161 "Trying to set more workers active than there are");
162 _active_workers = MIN2(v, _total_workers);
163 add_workers(false /* exit_on_failure */);
164 assert(v != 0, "Trying to set active workers to 0");
165 assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers,
166 "Unless dynamic should use total workers");
167 log_info(gc, task)("GC Workers: using %d out of %d", _active_workers, _total_workers);
168 }
169
170 // Add GC workers as needed.
171 void add_workers(bool initializing);
172
173 // Add specified number of GC workers
174 void add_workers(uint active_workers, bool initializing);
175
176 // Return the Ith worker.
177 AbstractGangWorker* worker(uint i) const;
178
179 void threads_do(ThreadClosure* tc) const;
180
181 // Create a GC worker and install it into the work gang.
182 virtual AbstractGangWorker* install_worker(uint which);
183
184 // Debugging.
185 const char* name() const { return _name; }
186
187 // Printing
188 void print_worker_threads_on(outputStream *st) const;
189 void print_worker_threads() const {
190 print_worker_threads_on(tty);
191 }
192
193 protected:
200 friend class GangWorker;
201
202 // Never deleted.
203 ~WorkGang();
204
205 GangTaskDispatcher* const _dispatcher;
206 GangTaskDispatcher* dispatcher() const {
207 return _dispatcher;
208 }
209
210 public:
211 WorkGang(const char* name,
212 uint workers,
213 bool are_GC_task_threads,
214 bool are_ConcurrentGC_threads);
215
216 // Run a task using the current active number of workers, returns when the task is done.
217 virtual void run_task(AbstractGangTask* task);
218 // Run a task with the given number of workers, returns
219 // when the task is done. The number of workers must be at most the number of
220 // active workers.
221 void run_task(AbstractGangTask* task, uint num_workers);
222
223 protected:
224 virtual AbstractGangWorker* allocate_worker(uint which);
225 };
226
227 // Several instances of this class run in parallel as workers for a gang.
228 class AbstractGangWorker: public WorkerThread {
229 public:
230 AbstractGangWorker(AbstractWorkGang* gang, uint id);
231
232 // The only real method: run a task for the gang.
233 virtual void run();
234 // Predicate for Thread
235 virtual bool is_GC_task_thread() const;
236 virtual bool is_ConcurrentGC_thread() const;
237 // Printing
238 void print_on(outputStream* st) const;
239 virtual void print() const { print_on(tty); }
240
|
153 "_active_workers: %u > _total_workers: %u", _active_workers, _total_workers);
154 assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers,
155 "Unless dynamic should use total workers");
156 return _active_workers;
157 }
158
159 void set_active_workers(uint v) {
160 assert(v <= _total_workers,
161 "Trying to set more workers active than there are");
162 _active_workers = MIN2(v, _total_workers);
163 add_workers(false /* exit_on_failure */);
164 assert(v != 0, "Trying to set active workers to 0");
165 assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers,
166 "Unless dynamic should use total workers");
167 log_info(gc, task)("GC Workers: using %d out of %d", _active_workers, _total_workers);
168 }
169
170 // Add GC workers as needed.
171 void add_workers(bool initializing);
172
173 // Add GC workers as needed to reach the specified number of workers.
174 void add_workers(uint active_workers, bool initializing);
175
176 // Return the Ith worker.
177 AbstractGangWorker* worker(uint i) const;
178
179 void threads_do(ThreadClosure* tc) const;
180
181 // Create a GC worker and install it into the work gang.
182 virtual AbstractGangWorker* install_worker(uint which);
183
184 // Debugging.
185 const char* name() const { return _name; }
186
187 // Printing
188 void print_worker_threads_on(outputStream *st) const;
189 void print_worker_threads() const {
190 print_worker_threads_on(tty);
191 }
192
193 protected:
200 friend class GangWorker;
201
202 // Never deleted.
203 ~WorkGang();
204
205 GangTaskDispatcher* const _dispatcher;
206 GangTaskDispatcher* dispatcher() const {
207 return _dispatcher;
208 }
209
210 public:
211 WorkGang(const char* name,
212 uint workers,
213 bool are_GC_task_threads,
214 bool are_ConcurrentGC_threads);
215
216 // Run a task using the current active number of workers, returns when the task is done.
217 virtual void run_task(AbstractGangTask* task);
218 // Run a task with the given number of workers, returns
219 // when the task is done. The number of workers must be at most the number of
220 // active workers. Additional workers may be created if an insufficient
221 // number currently exists.
222 void run_task(AbstractGangTask* task, uint num_workers);
223
224 protected:
225 virtual AbstractGangWorker* allocate_worker(uint which);
226 };
227
228 // Several instances of this class run in parallel as workers for a gang.
229 class AbstractGangWorker: public WorkerThread {
230 public:
231 AbstractGangWorker(AbstractWorkGang* gang, uint id);
232
233 // The only real method: run a task for the gang.
234 virtual void run();
235 // Predicate for Thread
236 virtual bool is_GC_task_thread() const;
237 virtual bool is_ConcurrentGC_thread() const;
238 // Printing
239 void print_on(outputStream* st) const;
240 virtual void print() const { print_on(tty); }
241
|