< prev index next >

src/hotspot/share/gc/shared/workgroup.cpp

Print this page

        

@@ -177,95 +177,16 @@
       _end_semaphore->signal();
     }
   }
 };
 
-class MutexGangTaskDispatcher : public GangTaskDispatcher {
-  AbstractGangTask* _task;
-
-  volatile uint _started;
-  volatile uint _finished;
-  volatile uint _num_workers;
-
-  Monitor* _monitor;
-
- public:
-  MutexGangTaskDispatcher() :
-    _task(NULL),
-    _started(0),
-    _finished(0),
-    _num_workers(0),
-    _monitor(new Monitor(Monitor::leaf, "WorkGang dispatcher lock", false, Monitor::_safepoint_check_never)) {
-  }
-
-  ~MutexGangTaskDispatcher() {
-    delete _monitor;
-  }
-
-  void coordinator_execute_on_workers(AbstractGangTask* task, uint num_workers, bool add_foreground_work) {
-    MonitorLocker ml(_monitor, Mutex::_no_safepoint_check_flag);
-
-    _task        = task;
-    _num_workers = num_workers;
-
-    // Tell the workers to get to work.
-    _monitor->notify_all();
-
-    run_foreground_task_if_needed(task, num_workers, add_foreground_work);
-
-    // Wait for them to finish.
-    while (_finished < _num_workers) {
-      ml.wait();
-    }
-
-    _task        = NULL;
-    _num_workers = 0;
-    _started     = 0;
-    _finished    = 0;
-  }
-
-  WorkData worker_wait_for_task() {
-    MonitorLocker ml(_monitor, Mutex::_no_safepoint_check_flag);
-
-    while (_num_workers == 0 || _started == _num_workers) {
-      _monitor->wait();
-    }
-
-    _started++;
-
-    // Subtract one to get a zero-indexed worker id.
-    uint worker_id = _started - 1;
-
-    return WorkData(_task, worker_id);
-  }
-
-  void worker_done_with_task() {
-    MonitorLocker ml(_monitor, Mutex::_no_safepoint_check_flag);
-
-    _finished++;
-
-    if (_finished == _num_workers) {
-      // This will wake up all workers and not only the coordinator.
-      _monitor->notify_all();
-    }
-  }
-};
-
-static GangTaskDispatcher* create_dispatcher() {
-  if (UseSemaphoreGCThreadsSynchronization) {
-    return new SemaphoreGangTaskDispatcher();
-  }
-
-  return new MutexGangTaskDispatcher();
-}
-
 WorkGang::WorkGang(const char* name,
                    uint  workers,
                    bool  are_GC_task_threads,
                    bool  are_ConcurrentGC_threads) :
     AbstractWorkGang(name, workers, are_GC_task_threads, are_ConcurrentGC_threads),
-    _dispatcher(create_dispatcher())
+    _dispatcher(new SemaphoreGangTaskDispatcher())
 { }
 
 WorkGang::~WorkGang() {
   delete _dispatcher;
 }
< prev index next >