src/share/vm/utilities/workgroup.hpp

Print this page




   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  *
  23  */
  24 














  25 // Forward declarations of classes defined here
  26 
  27 class WorkGang;
  28 class GangWorker;
  29 class YieldingFlexibleGangWorker;
  30 class YieldingFlexibleGangTask;
  31 class WorkData;
  32 class AbstractWorkGang;
  33 
  34 // An abstract task to be worked on by a gang.
  35 // You subclass this to supply your own work() method
  36 class AbstractGangTask VALUE_OBJ_CLASS_SPEC {
  37 public:
  38   // The abstract work method.
  39   // The argument tells you which member of the gang you are.
  40   virtual void work(int i) = 0;
  41 
  42   // This method configures the task for proper termination.
  43   // Some tasks do not have any requirements on termination
  44   // and may inherit this method that does nothing.  Some


 441   static FreeIdSetPtr _sets[NSets];
 442   static bool _stat_init;
 443   int _index;
 444 
 445 public:
 446   FreeIdSet(int sz, Monitor* mon);
 447   ~FreeIdSet();
 448 
 449   static void set_safepoint(bool b);
 450 
 451   // Attempt to claim the given id permanently.  Returns "true" iff
 452   // successful.
 453   bool claim_perm_id(int i);
 454 
 455   // Returns an unclaimed parallel id (waiting for one to be released if
 456   // necessary).  Returns "-1" if a GC wakes up a wait for an id.
 457   int claim_par_id();
 458 
 459   void release_par_id(int id);
 460 };




   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  *
  23  */
  24 
  25 #ifndef SHARE_VM_UTILITIES_WORKGROUP_HPP
  26 #define SHARE_VM_UTILITIES_WORKGROUP_HPP
  27 
  28 #include "utilities/taskqueue.hpp"
  29 #ifdef TARGET_OS_FAMILY_linux
  30 # include "thread_linux.inline.hpp"
  31 #endif
  32 #ifdef TARGET_OS_FAMILY_solaris
  33 # include "thread_solaris.inline.hpp"
  34 #endif
  35 #ifdef TARGET_OS_FAMILY_windows
  36 # include "thread_windows.inline.hpp"
  37 #endif
  38 
  39 // Forward declarations of classes defined here
  40 
  41 class WorkGang;
  42 class GangWorker;
  43 class YieldingFlexibleGangWorker;
  44 class YieldingFlexibleGangTask;
  45 class WorkData;
  46 class AbstractWorkGang;
  47 
  48 // An abstract task to be worked on by a gang.
  49 // You subclass this to supply your own work() method
  50 class AbstractGangTask VALUE_OBJ_CLASS_SPEC {
  51 public:
  52   // The abstract work method.
  53   // The argument tells you which member of the gang you are.
  54   virtual void work(int i) = 0;
  55 
  56   // This method configures the task for proper termination.
  57   // Some tasks do not have any requirements on termination
  58   // and may inherit this method that does nothing.  Some


 455   static FreeIdSetPtr _sets[NSets];
 456   static bool _stat_init;
 457   int _index;
 458 
 459 public:
 460   FreeIdSet(int sz, Monitor* mon);
 461   ~FreeIdSet();
 462 
 463   static void set_safepoint(bool b);
 464 
 465   // Attempt to claim the given id permanently.  Returns "true" iff
 466   // successful.
 467   bool claim_perm_id(int i);
 468 
 469   // Returns an unclaimed parallel id (waiting for one to be released if
 470   // necessary).  Returns "-1" if a GC wakes up a wait for an id.
 471   int claim_par_id();
 472 
 473   void release_par_id(int id);
 474 };
 475 
 476 #endif // SHARE_VM_UTILITIES_WORKGROUP_HPP