< prev index next >

src/share/vm/utilities/workgroup.hpp

Print this page
rev 8068 : 6407976: GC worker number should be unsigned
Reviewed-by: jwilhelm
   1 /*
   2  * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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  *


  47 class WorkGang;
  48 class GangWorker;
  49 class YieldingFlexibleGangWorker;
  50 class YieldingFlexibleGangTask;
  51 class WorkData;
  52 class AbstractWorkGang;
  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 public:
  58   // The abstract work method.
  59   // The argument tells you which member of the gang you are.
  60   virtual void work(uint worker_id) = 0;
  61 
  62   // This method configures the task for proper termination.
  63   // Some tasks do not have any requirements on termination
  64   // and may inherit this method that does nothing.  Some
  65   // tasks do some coordination on termination and override
  66   // this method to implement that coordination.
  67   virtual void set_for_termination(int active_workers) {};
  68 
  69   // Debugging accessor for the name.
  70   const char* name() const PRODUCT_RETURN_(return NULL;);
  71   int counter() { return _counter; }
  72   void set_counter(int value) { _counter = value; }
  73   int *address_of_counter() { return &_counter; }
  74 
  75   // RTTI
  76   NOT_PRODUCT(virtual bool is_YieldingFlexibleGang_task() const {
  77     return false;
  78   })
  79 
  80 private:
  81   NOT_PRODUCT(const char* _name;)
  82   // ??? Should a task have a priority associated with it?
  83   // ??? Or can the run method adjust priority as needed?
  84   int _counter;
  85 
  86 protected:
  87   // Constructor and desctructor: only construct subclasses.
  88   AbstractGangTask(const char* name)
  89   {
  90     NOT_PRODUCT(_name = name);
  91     _counter = 0;
  92   }
  93   ~AbstractGangTask() { }
  94 
  95 public:
  96 };
  97 
  98 class AbstractGangTaskWOopQueues : public AbstractGangTask {
  99   OopTaskQueueSet*       _queues;
 100   ParallelTaskTerminator _terminator;
 101  public:
 102   AbstractGangTaskWOopQueues(const char* name, OopTaskQueueSet* queues) :
 103     AbstractGangTask(name), _queues(queues), _terminator(0, _queues) {}
 104   ParallelTaskTerminator* terminator() { return &_terminator; }
 105   virtual void set_for_termination(int active_workers) {
 106     terminator()->reset_for_reuse(active_workers);
 107   }
 108   OopTaskQueueSet* queues() { return _queues; }
 109 };
 110 
 111 
 112 // Class AbstractWorkGang:
 113 // An abstract class representing a gang of workers.
 114 // You subclass this to supply an implementation of run_task().
 115 class AbstractWorkGang: public CHeapObj<mtInternal> {
 116   // Here's the public interface to this class.
 117 public:
 118   // Constructor and destructor.
 119   AbstractWorkGang(const char* name, bool are_GC_task_threads,
 120                    bool are_ConcurrentGC_threads);
 121   ~AbstractWorkGang();
 122   // Run a task, returns when the task is done (or terminated).
 123   virtual void run_task(AbstractGangTask* task) = 0;
 124   // Stop and terminate all workers.
 125   virtual void stop();


   1 /*
   2  * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  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  *


  47 class WorkGang;
  48 class GangWorker;
  49 class YieldingFlexibleGangWorker;
  50 class YieldingFlexibleGangTask;
  51 class WorkData;
  52 class AbstractWorkGang;
  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 public:
  58   // The abstract work method.
  59   // The argument tells you which member of the gang you are.
  60   virtual void work(uint worker_id) = 0;
  61 
  62   // This method configures the task for proper termination.
  63   // Some tasks do not have any requirements on termination
  64   // and may inherit this method that does nothing.  Some
  65   // tasks do some coordination on termination and override
  66   // this method to implement that coordination.
  67   virtual void set_for_termination(uint active_workers) {};
  68 
  69   // Debugging accessor for the name.
  70   const char* name() const PRODUCT_RETURN_(return NULL;);
  71   int counter() { return _counter; }
  72   void set_counter(int value) { _counter = value; }
  73   int *address_of_counter() { return &_counter; }
  74 
  75   // RTTI
  76   NOT_PRODUCT(virtual bool is_YieldingFlexibleGang_task() const {
  77     return false;
  78   })
  79 
  80 private:
  81   NOT_PRODUCT(const char* _name;)
  82   // ??? Should a task have a priority associated with it?
  83   // ??? Or can the run method adjust priority as needed?
  84   int _counter;
  85 
  86 protected:
  87   // Constructor and desctructor: only construct subclasses.
  88   AbstractGangTask(const char* name)
  89   {
  90     NOT_PRODUCT(_name = name);
  91     _counter = 0;
  92   }
  93   ~AbstractGangTask() { }
  94 
  95 public:
  96 };
  97 
  98 class AbstractGangTaskWOopQueues : public AbstractGangTask {
  99   OopTaskQueueSet*       _queues;
 100   ParallelTaskTerminator _terminator;
 101  public:
 102   AbstractGangTaskWOopQueues(const char* name, OopTaskQueueSet* queues) :
 103     AbstractGangTask(name), _queues(queues), _terminator(0, _queues) {}
 104   ParallelTaskTerminator* terminator() { return &_terminator; }
 105   virtual void set_for_termination(uint active_workers) {
 106     terminator()->reset_for_reuse(active_workers);
 107   }
 108   OopTaskQueueSet* queues() { return _queues; }
 109 };
 110 
 111 
 112 // Class AbstractWorkGang:
 113 // An abstract class representing a gang of workers.
 114 // You subclass this to supply an implementation of run_task().
 115 class AbstractWorkGang: public CHeapObj<mtInternal> {
 116   // Here's the public interface to this class.
 117 public:
 118   // Constructor and destructor.
 119   AbstractWorkGang(const char* name, bool are_GC_task_threads,
 120                    bool are_ConcurrentGC_threads);
 121   ~AbstractWorkGang();
 122   // Run a task, returns when the task is done (or terminated).
 123   virtual void run_task(AbstractGangTask* task) = 0;
 124   // Stop and terminate all workers.
 125   virtual void stop();


< prev index next >