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_GC_SHENANDOAH_SHENANDOAHTASKQUEUE_HPP
26 #define SHARE_GC_SHENANDOAH_SHENANDOAHTASKQUEUE_HPP
27 #include "gc/shared/owstTaskTerminator.hpp"
28 #include "gc/shared/taskqueue.hpp"
29 #include "memory/allocation.hpp"
30 #include "runtime/atomic.hpp"
31 #include "runtime/mutex.hpp"
32 #include "runtime/thread.hpp"
33
34 template<class E, MEMFLAGS F, unsigned int N = TASKQUEUE_SIZE>
35 class BufferedOverflowTaskQueue: public OverflowTaskQueue<E, F, N>
36 {
37 public:
38 typedef OverflowTaskQueue<E, F, N> taskqueue_t;
39
40 BufferedOverflowTaskQueue() : _buf_empty(true) {};
41
42 TASKQUEUE_STATS_ONLY(using taskqueue_t::stats;)
43
44 // Push task t into the queue. Returns true on success.
45 inline bool push(E t);
46
47 // Attempt to pop from the queue. Returns true on success.
323 void clear();
324
325 #if TASKQUEUE_STATS
326 static void print_taskqueue_stats_hdr(outputStream* const st);
327 void print_taskqueue_stats() const;
328 void reset_taskqueue_stats();
329 #endif // TASKQUEUE_STATS
330 };
331
332 class ShenandoahTerminatorTerminator : public TerminatorTerminator {
333 private:
334 ShenandoahHeap* _heap;
335 public:
336 ShenandoahTerminatorTerminator(ShenandoahHeap* const heap) : _heap(heap) { }
337 // return true, terminates immediately, even if there's remaining work left
338 virtual bool should_exit_termination() { return _heap->cancelled_gc(); }
339 };
340
341 class ShenandoahTaskTerminator : public StackObj {
342 private:
343 OWSTTaskTerminator _terminator;
344 public:
345 ShenandoahTaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set);
346
347 bool offer_termination(ShenandoahTerminatorTerminator* terminator) {
348 return _terminator.offer_termination(terminator);
349 }
350
351 void reset_for_reuse() { _terminator.reset_for_reuse(); }
352 bool offer_termination() { return offer_termination((ShenandoahTerminatorTerminator*)NULL); }
353 };
354
355 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHTASKQUEUE_HPP
|
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_GC_SHENANDOAH_SHENANDOAHTASKQUEUE_HPP
26 #define SHARE_GC_SHENANDOAH_SHENANDOAHTASKQUEUE_HPP
27
28 #include "gc/shared/taskTerminator.hpp"
29 #include "gc/shared/taskqueue.hpp"
30 #include "memory/allocation.hpp"
31 #include "runtime/atomic.hpp"
32 #include "runtime/mutex.hpp"
33 #include "runtime/thread.hpp"
34
35 template<class E, MEMFLAGS F, unsigned int N = TASKQUEUE_SIZE>
36 class BufferedOverflowTaskQueue: public OverflowTaskQueue<E, F, N>
37 {
38 public:
39 typedef OverflowTaskQueue<E, F, N> taskqueue_t;
40
41 BufferedOverflowTaskQueue() : _buf_empty(true) {};
42
43 TASKQUEUE_STATS_ONLY(using taskqueue_t::stats;)
44
45 // Push task t into the queue. Returns true on success.
46 inline bool push(E t);
47
48 // Attempt to pop from the queue. Returns true on success.
324 void clear();
325
326 #if TASKQUEUE_STATS
327 static void print_taskqueue_stats_hdr(outputStream* const st);
328 void print_taskqueue_stats() const;
329 void reset_taskqueue_stats();
330 #endif // TASKQUEUE_STATS
331 };
332
333 class ShenandoahTerminatorTerminator : public TerminatorTerminator {
334 private:
335 ShenandoahHeap* _heap;
336 public:
337 ShenandoahTerminatorTerminator(ShenandoahHeap* const heap) : _heap(heap) { }
338 // return true, terminates immediately, even if there's remaining work left
339 virtual bool should_exit_termination() { return _heap->cancelled_gc(); }
340 };
341
342 class ShenandoahTaskTerminator : public StackObj {
343 private:
344 TaskTerminator _terminator;
345 public:
346 ShenandoahTaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set);
347
348 bool offer_termination(ShenandoahTerminatorTerminator* terminator) {
349 return _terminator.offer_termination(terminator);
350 }
351
352 void reset_for_reuse() { _terminator.reset_for_reuse(); }
353 bool offer_termination() { return offer_termination((ShenandoahTerminatorTerminator*)NULL); }
354 };
355
356 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHTASKQUEUE_HPP
|