493 // NULL, then it is ignored.
494 virtual bool offer_termination(TerminatorTerminator* terminator);
495
496 // Reset the terminator, so that it may be reused again.
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 #ifdef _MSC_VER
514 #pragma warning(push)
515 // warning C4521: multiple copy constructors specified
516 #pragma warning(disable:4521)
517 // warning C4522: multiple assignment operators specified
518 #pragma warning(disable:4522)
519 #endif
520
521 class TaskTerminator : public StackObj {
522 private:
523 ParallelTaskTerminator* _terminator;
524
525 // Disable following copy constructors and assignment operator
526 TaskTerminator(TaskTerminator& o) { }
527 TaskTerminator(const TaskTerminator& o) { }
528 TaskTerminator& operator=(TaskTerminator& o) { return *this; }
529 public:
530 TaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set);
531 ~TaskTerminator();
532
533 // Move assignment
534 TaskTerminator& operator=(const TaskTerminator& o);
535
536 ParallelTaskTerminator* terminator() const {
537 return _terminator;
538 }
539 };
540 #ifdef _MSC_VER
541 #pragma warning(pop)
542 #endif
543
544
545 typedef GenericTaskQueue<oop, mtGC> OopTaskQueue;
546 typedef GenericTaskQueueSet<OopTaskQueue, mtGC> OopTaskQueueSet;
547
548 #ifdef _MSC_VER
549 #pragma warning(push)
550 // warning C4522: multiple assignment operators specified
551 #pragma warning(disable:4522)
552 #endif
553
554 // This is a container class for either an oop* or a narrowOop*.
555 // Both are pushed onto a task queue and the consumer will test is_narrow()
556 // to determine which should be processed.
557 class StarTask {
558 void* _holder; // either union oop* or narrowOop*
559
560 enum { COMPRESSED_OOP_MASK = 1 };
561
562 public:
563 StarTask(narrowOop* p) {
|
493 // NULL, then it is ignored.
494 virtual bool offer_termination(TerminatorTerminator* terminator);
495
496 // Reset the terminator, so that it may be reused again.
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()
540 // to determine which should be processed.
541 class StarTask {
542 void* _holder; // either union oop* or narrowOop*
543
544 enum { COMPRESSED_OOP_MASK = 1 };
545
546 public:
547 StarTask(narrowOop* p) {
|