src/share/vm/utilities/workgroup.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hs25_8011661 Sdiff src/share/vm/utilities

src/share/vm/utilities/workgroup.cpp

Print this page




  62 
  63 GangWorker* WorkGang::allocate_worker(uint which) {
  64   GangWorker* new_worker = new GangWorker(this, which);
  65   return new_worker;
  66 }
  67 
  68 // The current implementation will exit if the allocation
  69 // of any worker fails.  Still, return a boolean so that
  70 // a future implementation can possibly do a partial
  71 // initialization of the workers and report such to the
  72 // caller.
  73 bool WorkGang::initialize_workers() {
  74 
  75   if (TraceWorkGang) {
  76     tty->print_cr("Constructing work gang %s with %d threads",
  77                   name(),
  78                   total_workers());
  79   }
  80   _gang_workers = NEW_C_HEAP_ARRAY(GangWorker*, total_workers(), mtInternal);
  81   if (gang_workers() == NULL) {
  82     vm_exit_out_of_memory(0, "Cannot create GangWorker array.");
  83     return false;
  84   }
  85   os::ThreadType worker_type;
  86   if (are_ConcurrentGC_threads()) {
  87     worker_type = os::cgc_thread;
  88   } else {
  89     worker_type = os::pgc_thread;
  90   }
  91   for (uint worker = 0; worker < total_workers(); worker += 1) {
  92     GangWorker* new_worker = allocate_worker(worker);
  93     assert(new_worker != NULL, "Failed to allocate GangWorker");
  94     _gang_workers[worker] = new_worker;
  95     if (new_worker == NULL || !os::create_thread(new_worker, worker_type)) {
  96       vm_exit_out_of_memory(0, "Cannot create worker GC thread. Out of system resources.");

  97       return false;
  98     }
  99     if (!DisableStartThread) {
 100       os::start_thread(new_worker);
 101     }
 102   }
 103   return true;
 104 }
 105 
 106 AbstractWorkGang::~AbstractWorkGang() {
 107   if (TraceWorkGang) {
 108     tty->print_cr("Destructing work gang %s", name());
 109   }
 110   stop();   // stop all the workers
 111   for (uint worker = 0; worker < total_workers(); worker += 1) {
 112     delete gang_worker(worker);
 113   }
 114   delete gang_workers();
 115   delete monitor();
 116 }




  62 
  63 GangWorker* WorkGang::allocate_worker(uint which) {
  64   GangWorker* new_worker = new GangWorker(this, which);
  65   return new_worker;
  66 }
  67 
  68 // The current implementation will exit if the allocation
  69 // of any worker fails.  Still, return a boolean so that
  70 // a future implementation can possibly do a partial
  71 // initialization of the workers and report such to the
  72 // caller.
  73 bool WorkGang::initialize_workers() {
  74 
  75   if (TraceWorkGang) {
  76     tty->print_cr("Constructing work gang %s with %d threads",
  77                   name(),
  78                   total_workers());
  79   }
  80   _gang_workers = NEW_C_HEAP_ARRAY(GangWorker*, total_workers(), mtInternal);
  81   if (gang_workers() == NULL) {
  82     vm_exit_out_of_memory(0, OOM_MALLOC_ERROR, "Cannot create GangWorker array.");
  83     return false;
  84   }
  85   os::ThreadType worker_type;
  86   if (are_ConcurrentGC_threads()) {
  87     worker_type = os::cgc_thread;
  88   } else {
  89     worker_type = os::pgc_thread;
  90   }
  91   for (uint worker = 0; worker < total_workers(); worker += 1) {
  92     GangWorker* new_worker = allocate_worker(worker);
  93     assert(new_worker != NULL, "Failed to allocate GangWorker");
  94     _gang_workers[worker] = new_worker;
  95     if (new_worker == NULL || !os::create_thread(new_worker, worker_type)) {
  96       vm_exit_out_of_memory(0, OOM_MALLOC_ERROR,
  97               "Cannot create worker GC thread. Out of system resources.");
  98       return false;
  99     }
 100     if (!DisableStartThread) {
 101       os::start_thread(new_worker);
 102     }
 103   }
 104   return true;
 105 }
 106 
 107 AbstractWorkGang::~AbstractWorkGang() {
 108   if (TraceWorkGang) {
 109     tty->print_cr("Destructing work gang %s", name());
 110   }
 111   stop();   // stop all the workers
 112   for (uint worker = 0; worker < total_workers(); worker += 1) {
 113     delete gang_worker(worker);
 114   }
 115   delete gang_workers();
 116   delete monitor();
 117 }


src/share/vm/utilities/workgroup.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File