Path: blob/master/src/hotspot/share/jfr/utilities/jfrThreadIterator.hpp
41152 views
/*1* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 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 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_JFR_UTILITIES_JFRTHREADITERATOR_HPP25#define SHARE_VM_JFR_UTILITIES_JFRTHREADITERATOR_HPP2627#include "memory/allocation.hpp"28#include "runtime/nonJavaThread.hpp"29#include "runtime/thread.hpp"30#include "runtime/threadSMR.hpp"3132template <typename Adapter, typename AP = StackObj>33class JfrThreadIterator : public AP {34private:35Adapter _adapter;36public:37JfrThreadIterator(bool live_only = true) : _adapter(live_only) {}38typename Adapter::Type* next() {39assert(has_next(), "invariant");40return _adapter.next();41}42bool has_next() const {43return _adapter.has_next();44}45};4647class JfrJavaThreadIteratorAdapter {48private:49JavaThreadIteratorWithHandle _iter;50JavaThread* _next;51bool _live_only;52public:53typedef JavaThread Type;54JfrJavaThreadIteratorAdapter(bool live_only = true);55bool has_next() const {56return _next != NULL;57}58Type* next();59};6061class JfrNonJavaThreadIteratorAdapter {62private:63NonJavaThread::Iterator _iter;64NonJavaThread* _next;65public:66typedef NonJavaThread Type;67JfrNonJavaThreadIteratorAdapter(bool live_only = true);68bool has_next() const;69Type* next();70};7172typedef JfrThreadIterator<JfrJavaThreadIteratorAdapter, StackObj> JfrJavaThreadIterator;73typedef JfrThreadIterator<JfrNonJavaThreadIteratorAdapter, StackObj> JfrNonJavaThreadIterator;7475#endif // SHARE_VM_JFR_UTILITIES_JFRTHREADITERATOR_HPP767778