8155232: Augment Workgang to run task with a given number of threads
Add a method to run a WorkGang with a set number of threads. Reviewed-by: stefank, jmasa, mgerdin
This commit is contained in:
parent
85deb5aa7e
commit
238fada762
@ -255,7 +255,15 @@ AbstractGangWorker* WorkGang::allocate_worker(uint worker_id) {
|
||||
}
|
||||
|
||||
void WorkGang::run_task(AbstractGangTask* task) {
|
||||
_dispatcher->coordinator_execute_on_workers(task, active_workers());
|
||||
run_task(task, active_workers());
|
||||
}
|
||||
|
||||
void WorkGang::run_task(AbstractGangTask* task, uint num_workers) {
|
||||
guarantee(num_workers <= active_workers(),
|
||||
"Trying to execute task %s with %u workers which is more than the amount of active workers %u.",
|
||||
task->name(), num_workers, active_workers());
|
||||
guarantee(num_workers > 0, "Trying to execute task %s with zero workers", task->name());
|
||||
_dispatcher->coordinator_execute_on_workers(task, num_workers);
|
||||
}
|
||||
|
||||
AbstractGangWorker::AbstractGangWorker(AbstractWorkGang* gang, uint id) {
|
||||
|
@ -192,8 +192,12 @@ public:
|
||||
bool are_GC_task_threads,
|
||||
bool are_ConcurrentGC_threads);
|
||||
|
||||
// Run a task, returns when the task is done.
|
||||
// Run a task using the current active number of workers, returns when the task is done.
|
||||
virtual void run_task(AbstractGangTask* task);
|
||||
// Run a task with the given number of workers, returns
|
||||
// when the task is done. The number of workers must be at most the number of
|
||||
// active workers.
|
||||
void run_task(AbstractGangTask* task, uint num_workers);
|
||||
|
||||
protected:
|
||||
virtual AbstractGangWorker* allocate_worker(uint which);
|
||||
|
Loading…
Reference in New Issue
Block a user