< prev index next >

src/share/vm/gc/shared/workgroup.hpp

Print this page




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_SHARED_WORKGROUP_HPP
  26 #define SHARE_VM_GC_SHARED_WORKGROUP_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "runtime/globals.hpp"
  30 #include "runtime/thread.hpp"

  31 #include "utilities/debug.hpp"
  32 #include "utilities/globalDefinitions.hpp"
  33 
  34 // Task class hierarchy:
  35 //   AbstractGangTask
  36 //
  37 // Gang/Group class hierarchy:
  38 //   AbstractWorkGang
  39 //     WorkGang
  40 //     YieldingFlexibleWorkGang (defined in another file)
  41 //
  42 // Worker class hierarchy:
  43 //   AbstractGangWorker (subclass of WorkerThread)
  44 //     GangWorker
  45 //     YieldingFlexibleGangWorker   (defined in another file)
  46 
  47 // Forward declarations of classes defined here
  48 
  49 class AbstractGangWorker;
  50 class Semaphore;
  51 class WorkGang;
  52 
  53 // An abstract task to be worked on by a gang.
  54 // You subclass this to supply your own work() method
  55 class AbstractGangTask VALUE_OBJ_CLASS_SPEC {
  56   const char* _name;

  57 
  58  public:
  59   AbstractGangTask(const char* name) : _name(name) {}



  60 
  61   // The abstract work method.
  62   // The argument tells you which member of the gang you are.
  63   virtual void work(uint worker_id) = 0;
  64 
  65   // Debugging accessor for the name.
  66   const char* name() const { return _name; }

  67 };
  68 
  69 struct WorkData {
  70   AbstractGangTask* _task;
  71   uint              _worker_id;
  72   WorkData(AbstractGangTask* task, uint worker_id) : _task(task), _worker_id(worker_id) {}
  73 };
  74 
  75 // Interface to handle the synchronization between the coordinator thread and the worker threads,
  76 // when a task is dispatched out to the worker threads.
  77 class GangTaskDispatcher : public CHeapObj<mtGC> {
  78  public:
  79   virtual ~GangTaskDispatcher() {}
  80 
  81   // Coordinator API.
  82 
  83   // Distributes the task out to num_workers workers.
  84   // Returns when the task has been completed by all workers.
  85   virtual void coordinator_execute_on_workers(AbstractGangTask* task, uint num_workers) = 0;
  86 




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_SHARED_WORKGROUP_HPP
  26 #define SHARE_VM_GC_SHARED_WORKGROUP_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "runtime/globals.hpp"
  30 #include "runtime/thread.hpp"
  31 #include "gc/shared/gcId.hpp"
  32 #include "utilities/debug.hpp"
  33 #include "utilities/globalDefinitions.hpp"
  34 
  35 // Task class hierarchy:
  36 //   AbstractGangTask
  37 //
  38 // Gang/Group class hierarchy:
  39 //   AbstractWorkGang
  40 //     WorkGang
  41 //     YieldingFlexibleWorkGang (defined in another file)
  42 //
  43 // Worker class hierarchy:
  44 //   AbstractGangWorker (subclass of WorkerThread)
  45 //     GangWorker
  46 //     YieldingFlexibleGangWorker   (defined in another file)
  47 
  48 // Forward declarations of classes defined here
  49 
  50 class AbstractGangWorker;
  51 class Semaphore;
  52 class WorkGang;
  53 
  54 // An abstract task to be worked on by a gang.
  55 // You subclass this to supply your own work() method
  56 class AbstractGangTask VALUE_OBJ_CLASS_SPEC {
  57   const char* _name;
  58   const uint _gc_id;
  59 
  60  public:
  61   AbstractGangTask(const char* name) :
  62     _name(name),
  63     _gc_id(GCId::current_raw()) // Use current_raw() here since the G1ParVerifyTask can be called outside of a GC (at VM exit)
  64  {}
  65 
  66   // The abstract work method.
  67   // The argument tells you which member of the gang you are.
  68   virtual void work(uint worker_id) = 0;
  69 
  70   // Debugging accessor for the name.
  71   const char* name() const { return _name; }
  72   const uint gc_id() const { return _gc_id; }
  73 };
  74 
  75 struct WorkData {
  76   AbstractGangTask* _task;
  77   uint              _worker_id;
  78   WorkData(AbstractGangTask* task, uint worker_id) : _task(task), _worker_id(worker_id) {}
  79 };
  80 
  81 // Interface to handle the synchronization between the coordinator thread and the worker threads,
  82 // when a task is dispatched out to the worker threads.
  83 class GangTaskDispatcher : public CHeapObj<mtGC> {
  84  public:
  85   virtual ~GangTaskDispatcher() {}
  86 
  87   // Coordinator API.
  88 
  89   // Distributes the task out to num_workers workers.
  90   // Returns when the task has been completed by all workers.
  91   virtual void coordinator_execute_on_workers(AbstractGangTask* task, uint num_workers) = 0;
  92 


< prev index next >