1 /*
   2  * Copyright (c) 2017, 2018, Red Hat, Inc. and/or its affiliates.
   3  *
   4  * This code is free software; you can redistribute it and/or modify it
   5  * under the terms of the GNU General Public License version 2 only, as
   6  * published by the Free Software Foundation.
   7  *
   8  * This code is distributed in the hope that it will be useful, but WITHOUT
   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHSTRINGDEDUPTHREAD_HPP
  25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHSTRINGDEDUPTHREAD_HPP
  26 
  27 #include "gc_implementation/shared/concurrentGCThread.hpp"
  28 #include "gc_implementation/shenandoah/shenandoahStrDedupQueue.hpp"
  29 #include "memory/iterator.hpp"
  30 
  31 class ShenandoahStrDedupStats;
  32 
  33 class ShenandoahStrDedupThread: public ConcurrentGCThread {
  34 private:
  35   ShenandoahStrDedupQueueSet*   _queues;
  36   QueueChunkedList**            _work_list;
  37   volatile size_t               _claimed;
  38 
  39 public:
  40   ShenandoahStrDedupThread(ShenandoahStrDedupQueueSet* queues);
  41   ~ShenandoahStrDedupThread();
  42 
  43   void clear_claimed() { _claimed = 0; }
  44   void parallel_oops_do(OopClosure* cl);
  45   void parallel_cleanup();
  46 
  47   // For verification only
  48   void oops_do_slow(OopClosure* cl);
  49 
  50   virtual void run();
  51   virtual void stop();
  52 
  53 private:
  54   bool poll(ShenandoahStrDedupStats* stats);
  55   bool is_work_list_empty() const;
  56 
  57   ShenandoahStrDedupQueueSet* queues() const {
  58     return _queues;
  59   }
  60 
  61   size_t claim();
  62 };
  63 
  64 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHSTRINGDEDUPTHREAD_HPP