< prev index next >

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

Print this page
rev 49680 : imported patch 6672778-partial-queue-trimming
   1 /*
   2  * Copyright (c) 2001, 2017, 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  *


 268   using TaskQueueSuper<N, F>::stats;
 269 #endif
 270 
 271 private:
 272   // Slow paths for push, pop_local.  (pop_global has no fast path.)
 273   bool push_slow(E t, uint dirty_n_elems);
 274   bool pop_local_slow(uint localBot, Age oldAge);
 275 
 276 public:
 277   typedef E element_type;
 278 
 279   // Initializes the queue to empty.
 280   GenericTaskQueue();
 281 
 282   void initialize();
 283 
 284   // Push the task "t" on the queue.  Returns "false" iff the queue is full.
 285   inline bool push(E t);
 286 
 287   // Attempts to claim a task from the "local" end of the queue (the most
 288   // recently pushed).  If successful, returns true and sets t to the task;
 289   // otherwise, returns false (the queue is empty).
 290   inline bool pop_local(volatile E& t);

 291 
 292   // Like pop_local(), but uses the "global" end of the queue (the least
 293   // recently pushed).
 294   bool pop_global(volatile E& t);
 295 
 296   // Delete any resource associated with the queue.
 297   ~GenericTaskQueue();
 298 
 299   // Apply fn to each element in the task queue.  The queue must not
 300   // be modified while iterating.
 301   template<typename Fn> void iterate(Fn fn);
 302 
 303 private:
 304   // Element array.
 305   volatile E* _elems;
 306 };
 307 
 308 template<class E, MEMFLAGS F, unsigned int N>
 309 GenericTaskQueue<E, F, N>::GenericTaskQueue() {
 310   assert(sizeof(Age) == sizeof(size_t), "Depends on this.");


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


 268   using TaskQueueSuper<N, F>::stats;
 269 #endif
 270 
 271 private:
 272   // Slow paths for push, pop_local.  (pop_global has no fast path.)
 273   bool push_slow(E t, uint dirty_n_elems);
 274   bool pop_local_slow(uint localBot, Age oldAge);
 275 
 276 public:
 277   typedef E element_type;
 278 
 279   // Initializes the queue to empty.
 280   GenericTaskQueue();
 281 
 282   void initialize();
 283 
 284   // Push the task "t" on the queue.  Returns "false" iff the queue is full.
 285   inline bool push(E t);
 286 
 287   // Attempts to claim a task from the "local" end of the queue (the most
 288   // recently pushed) as long as the number of entries exceeds the threshold. 
 289   // If successful, returns true and sets t to the task; otherwise, returns false
 290   // (the queue is empty or the number of elements below the threshold).
 291   inline bool pop_local(volatile E& t, uint threshold = 0);
 292   
 293   // Like pop_local(), but uses the "global" end of the queue (the least
 294   // recently pushed).
 295   bool pop_global(volatile E& t);
 296 
 297   // Delete any resource associated with the queue.
 298   ~GenericTaskQueue();
 299 
 300   // Apply fn to each element in the task queue.  The queue must not
 301   // be modified while iterating.
 302   template<typename Fn> void iterate(Fn fn);
 303 
 304 private:
 305   // Element array.
 306   volatile E* _elems;
 307 };
 308 
 309 template<class E, MEMFLAGS F, unsigned int N>
 310 GenericTaskQueue<E, F, N>::GenericTaskQueue() {
 311   assert(sizeof(Age) == sizeof(size_t), "Depends on this.");


< prev index next >