175
176 // An class representing a gang of workers.
177 class WorkGang: public AbstractWorkGang {
178 // To get access to the GangTaskDispatcher instance.
179 friend class GangWorker;
180
181 // Never deleted.
182 ~WorkGang();
183
184 GangTaskDispatcher* const _dispatcher;
185 GangTaskDispatcher* dispatcher() const {
186 return _dispatcher;
187 }
188
189 public:
190 WorkGang(const char* name,
191 uint workers,
192 bool are_GC_task_threads,
193 bool are_ConcurrentGC_threads);
194
195 // Run a task, returns when the task is done.
196 virtual void run_task(AbstractGangTask* task);
197
198 protected:
199 virtual AbstractGangWorker* allocate_worker(uint which);
200 };
201
202 // Several instances of this class run in parallel as workers for a gang.
203 class AbstractGangWorker: public WorkerThread {
204 public:
205 AbstractGangWorker(AbstractWorkGang* gang, uint id);
206
207 // The only real method: run a task for the gang.
208 virtual void run();
209 // Predicate for Thread
210 virtual bool is_GC_task_thread() const;
211 virtual bool is_ConcurrentGC_thread() const;
212 // Printing
213 void print_on(outputStream* st) const;
214 virtual void print() const { print_on(tty); }
215
216 protected:
|
175
176 // An class representing a gang of workers.
177 class WorkGang: public AbstractWorkGang {
178 // To get access to the GangTaskDispatcher instance.
179 friend class GangWorker;
180
181 // Never deleted.
182 ~WorkGang();
183
184 GangTaskDispatcher* const _dispatcher;
185 GangTaskDispatcher* dispatcher() const {
186 return _dispatcher;
187 }
188
189 public:
190 WorkGang(const char* name,
191 uint workers,
192 bool are_GC_task_threads,
193 bool are_ConcurrentGC_threads);
194
195 // Run a task using the current active number of workers, returns when the task is done.
196 virtual void run_task(AbstractGangTask* task);
197 // Run a task with the given number of workers, returns
198 // when the task is done. The number of workers must be at most the number of
199 // active workers.
200 void run_task(AbstractGangTask* task, uint num_workers);
201
202 protected:
203 virtual AbstractGangWorker* allocate_worker(uint which);
204 };
205
206 // Several instances of this class run in parallel as workers for a gang.
207 class AbstractGangWorker: public WorkerThread {
208 public:
209 AbstractGangWorker(AbstractWorkGang* gang, uint id);
210
211 // The only real method: run a task for the gang.
212 virtual void run();
213 // Predicate for Thread
214 virtual bool is_GC_task_thread() const;
215 virtual bool is_ConcurrentGC_thread() const;
216 // Printing
217 void print_on(outputStream* st) const;
218 virtual void print() const { print_on(tty); }
219
220 protected:
|