< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2002, 2019, 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  *


 306   // Aborts the barrier and wakes up any threads waiting for
 307   // the barrier to complete. The barrier will remain in the
 308   // aborted state until the next call to set_n_workers().
 309   void abort();
 310 };
 311 
 312 // A class to manage claiming of subtasks within a group of tasks.  The
 313 // subtasks will be identified by integer indices, usually elements of an
 314 // enumeration type.
 315 
 316 class SubTasksDone: public CHeapObj<mtInternal> {
 317   volatile uint* _tasks;
 318   uint _n_tasks;
 319   volatile uint _threads_completed;
 320 #ifdef ASSERT
 321   volatile uint _claimed;
 322 #endif
 323 
 324   // Set all tasks to unclaimed.
 325   void clear();


 326 
 327 public:
 328   // Initializes "this" to a state in which there are "n" tasks to be
 329   // processed, none of the which are originally claimed.  The number of
 330   // threads doing the tasks is initialized 1.
 331   SubTasksDone(uint n);
 332 
 333   // True iff the object is in a valid state.
 334   bool valid();
 335 
 336   // Attempt to claim the task "t", returning true if successful,
 337   // false if it has already been claimed.  The task "t" is required
 338   // to be within the range of "this".
 339   bool try_claim_task(uint t);
 340 
 341   // The calling thread asserts that it has attempted to claim all the
 342   // tasks that it will try to claim.  Every thread in the parallel task
 343   // must execute this.  (When the last thread does so, the task array is
 344   // cleared.)
 345   //


   1 /*
   2  * Copyright (c) 2002, 2020, 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  *


 306   // Aborts the barrier and wakes up any threads waiting for
 307   // the barrier to complete. The barrier will remain in the
 308   // aborted state until the next call to set_n_workers().
 309   void abort();
 310 };
 311 
 312 // A class to manage claiming of subtasks within a group of tasks.  The
 313 // subtasks will be identified by integer indices, usually elements of an
 314 // enumeration type.
 315 
 316 class SubTasksDone: public CHeapObj<mtInternal> {
 317   volatile uint* _tasks;
 318   uint _n_tasks;
 319   volatile uint _threads_completed;
 320 #ifdef ASSERT
 321   volatile uint _claimed;
 322 #endif
 323 
 324   // Set all tasks to unclaimed.
 325   void clear();
 326 
 327   NONCOPYABLE(SubTasksDone);
 328 
 329 public:
 330   // Initializes "this" to a state in which there are "n" tasks to be
 331   // processed, none of the which are originally claimed.  The number of
 332   // threads doing the tasks is initialized 1.
 333   SubTasksDone(uint n);
 334 
 335   // True iff the object is in a valid state.
 336   bool valid();
 337 
 338   // Attempt to claim the task "t", returning true if successful,
 339   // false if it has already been claimed.  The task "t" is required
 340   // to be within the range of "this".
 341   bool try_claim_task(uint t);
 342 
 343   // The calling thread asserts that it has attempted to claim all the
 344   // tasks that it will try to claim.  Every thread in the parallel task
 345   // must execute this.  (When the last thread does so, the task array is
 346   // cleared.)
 347   //


< prev index next >