src/hotspot/share/gc/shared/taskqueue.hpp
changeset 50953 0fad17c646c9
parent 49911 358be4680d12
child 51292 0538a5cdb474
equal deleted inserted replaced
50952:529e8aec67bd 50953:0fad17c646c9
    59   };
    59   };
    60 
    60 
    61 public:
    61 public:
    62   inline TaskQueueStats()       { reset(); }
    62   inline TaskQueueStats()       { reset(); }
    63 
    63 
    64   inline void record_push()     { ++_stats[push]; }
    64   inline void record_push()          { ++_stats[push]; }
    65   inline void record_pop()      { ++_stats[pop]; }
    65   inline void record_pop()           { ++_stats[pop]; }
    66   inline void record_pop_slow() { record_pop(); ++_stats[pop_slow]; }
    66   inline void record_pop_slow()      { record_pop(); ++_stats[pop_slow]; }
    67   inline void record_steal(bool success);
    67   inline void record_steal_attempt() { ++_stats[steal_attempt]; }
       
    68   inline void record_steal()         { ++_stats[steal]; }
    68   inline void record_overflow(size_t new_length);
    69   inline void record_overflow(size_t new_length);
    69 
    70 
    70   TaskQueueStats & operator +=(const TaskQueueStats & addend);
    71   TaskQueueStats & operator +=(const TaskQueueStats & addend);
    71 
    72 
    72   inline size_t get(StatId id) const { return _stats[id]; }
    73   inline size_t get(StatId id) const { return _stats[id]; }
    84 
    85 
    85 private:
    86 private:
    86   size_t                    _stats[last_stat_id];
    87   size_t                    _stats[last_stat_id];
    87   static const char * const _names[last_stat_id];
    88   static const char * const _names[last_stat_id];
    88 };
    89 };
    89 
       
    90 void TaskQueueStats::record_steal(bool success) {
       
    91   ++_stats[steal_attempt];
       
    92   if (success) ++_stats[steal];
       
    93 }
       
    94 
    90 
    95 void TaskQueueStats::record_overflow(size_t new_len) {
    91 void TaskQueueStats::record_overflow(size_t new_len) {
    96   ++_stats[overflow];
    92   ++_stats[overflow];
    97   if (new_len > _stats[overflow_max_len]) _stats[overflow_max_len] = new_len;
    93   if (new_len > _stats[overflow_max_len]) _stats[overflow_max_len] = new_len;
    98 }
    94 }
   362 template <MEMFLAGS F> class TaskQueueSetSuperImpl: public CHeapObj<F>, public TaskQueueSetSuper {
   358 template <MEMFLAGS F> class TaskQueueSetSuperImpl: public CHeapObj<F>, public TaskQueueSetSuper {
   363 };
   359 };
   364 
   360 
   365 template<class T, MEMFLAGS F>
   361 template<class T, MEMFLAGS F>
   366 class GenericTaskQueueSet: public TaskQueueSetSuperImpl<F> {
   362 class GenericTaskQueueSet: public TaskQueueSetSuperImpl<F> {
       
   363 public:
       
   364   typedef typename T::element_type E;
       
   365 
   367 private:
   366 private:
   368   uint _n;
   367   uint _n;
   369   T** _queues;
   368   T** _queues;
   370 
   369 
   371 public:
   370   bool steal_best_of_2(uint queue_num, int* seed, E& t);
   372   typedef typename T::element_type E;
   371 
   373 
   372 public:
   374   GenericTaskQueueSet(int n);
   373   GenericTaskQueueSet(int n);
   375   ~GenericTaskQueueSet();
   374   ~GenericTaskQueueSet();
   376 
       
   377   bool steal_best_of_2(uint queue_num, int* seed, E& t);
       
   378 
   375 
   379   void register_queue(uint i, T* q);
   376   void register_queue(uint i, T* q);
   380 
   377 
   381   T* queue(uint n);
   378   T* queue(uint n);
   382 
   379