< prev index next >

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

Print this page
rev 57095 : [mq]: use
rev 57096 : [mq]: trailing_semi


  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_GC_SHARED_TASKQUEUE_HPP
  26 #define SHARE_GC_SHARED_TASKQUEUE_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "memory/padded.hpp"
  30 #include "oops/oopsHierarchy.hpp"

  31 #include "utilities/ostream.hpp"
  32 #include "utilities/stack.hpp"
  33 
  34 // Simple TaskQueue stats that are collected by default in debug builds.
  35 
  36 #if !defined(TASKQUEUE_STATS) && defined(ASSERT)
  37 #define TASKQUEUE_STATS 1
  38 #elif !defined(TASKQUEUE_STATS)
  39 #define TASKQUEUE_STATS 0
  40 #endif
  41 
  42 #if TASKQUEUE_STATS
  43 #define TASKQUEUE_STATS_ONLY(code) code
  44 #else
  45 #define TASKQUEUE_STATS_ONLY(code)
  46 #endif // TASKQUEUE_STATS
  47 
  48 #if TASKQUEUE_STATS
  49 class TaskQueueStats {
  50 public:


 497   // The caller is responsible for ensuring that this is done
 498   // in an MT-safe manner, once the previous round of use of
 499   // the terminator is finished.
 500   void reset_for_reuse();
 501   // Same as above but the number of parallel threads is set to the
 502   // given number.
 503   void reset_for_reuse(uint n_threads);
 504 
 505 #ifdef TRACESPINNING
 506   static uint total_yields() { return _total_yields; }
 507   static uint total_spins() { return _total_spins; }
 508   static uint total_peeks() { return _total_peeks; }
 509   static void print_termination_counts();
 510 #endif
 511 };
 512 
 513 class TaskTerminator : public StackObj {
 514 private:
 515   ParallelTaskTerminator*  _terminator;
 516 
 517   // Noncopyable.
 518   TaskTerminator(const TaskTerminator&);
 519   TaskTerminator& operator=(const TaskTerminator&);
 520 public:
 521   TaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set);
 522   ~TaskTerminator();
 523 
 524   ParallelTaskTerminator* terminator() const {
 525     return _terminator;
 526   }
 527 };
 528 
 529 typedef GenericTaskQueue<oop, mtGC>             OopTaskQueue;
 530 typedef GenericTaskQueueSet<OopTaskQueue, mtGC> OopTaskQueueSet;
 531 
 532 #ifdef _MSC_VER
 533 #pragma warning(push)
 534 // warning C4522: multiple assignment operators specified
 535 #pragma warning(disable:4522)
 536 #endif
 537 
 538 // This is a container class for either an oop* or a narrowOop*.
 539 // Both are pushed onto a task queue and the consumer will test is_narrow()




  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_GC_SHARED_TASKQUEUE_HPP
  26 #define SHARE_GC_SHARED_TASKQUEUE_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "memory/padded.hpp"
  30 #include "oops/oopsHierarchy.hpp"
  31 #include "utilities/macros.hpp"
  32 #include "utilities/ostream.hpp"
  33 #include "utilities/stack.hpp"
  34 
  35 // Simple TaskQueue stats that are collected by default in debug builds.
  36 
  37 #if !defined(TASKQUEUE_STATS) && defined(ASSERT)
  38 #define TASKQUEUE_STATS 1
  39 #elif !defined(TASKQUEUE_STATS)
  40 #define TASKQUEUE_STATS 0
  41 #endif
  42 
  43 #if TASKQUEUE_STATS
  44 #define TASKQUEUE_STATS_ONLY(code) code
  45 #else
  46 #define TASKQUEUE_STATS_ONLY(code)
  47 #endif // TASKQUEUE_STATS
  48 
  49 #if TASKQUEUE_STATS
  50 class TaskQueueStats {
  51 public:


 498   // The caller is responsible for ensuring that this is done
 499   // in an MT-safe manner, once the previous round of use of
 500   // the terminator is finished.
 501   void reset_for_reuse();
 502   // Same as above but the number of parallel threads is set to the
 503   // given number.
 504   void reset_for_reuse(uint n_threads);
 505 
 506 #ifdef TRACESPINNING
 507   static uint total_yields() { return _total_yields; }
 508   static uint total_spins() { return _total_spins; }
 509   static uint total_peeks() { return _total_peeks; }
 510   static void print_termination_counts();
 511 #endif
 512 };
 513 
 514 class TaskTerminator : public StackObj {
 515 private:
 516   ParallelTaskTerminator*  _terminator;
 517 
 518   NONCOPYABLE(TaskTerminator);
 519 

 520 public:
 521   TaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set);
 522   ~TaskTerminator();
 523 
 524   ParallelTaskTerminator* terminator() const {
 525     return _terminator;
 526   }
 527 };
 528 
 529 typedef GenericTaskQueue<oop, mtGC>             OopTaskQueue;
 530 typedef GenericTaskQueueSet<OopTaskQueue, mtGC> OopTaskQueueSet;
 531 
 532 #ifdef _MSC_VER
 533 #pragma warning(push)
 534 // warning C4522: multiple assignment operators specified
 535 #pragma warning(disable:4522)
 536 #endif
 537 
 538 // This is a container class for either an oop* or a narrowOop*.
 539 // Both are pushed onto a task queue and the consumer will test is_narrow()


< prev index next >