--- a/src/hotspot/share/jfr/utilities/jfrIterator.hpp Fri May 17 15:53:21 2019 +0200
+++ b/src/hotspot/share/jfr/utilities/jfrIterator.hpp Fri May 17 16:02:27 2019 +0200
@@ -40,6 +40,14 @@
}
};
+template <typename Node>
+class StopOnEmptyCondition : public AllStatic {
+public:
+ static bool has_next(const Node* node) {
+ return node != NULL && !node->empty();
+ }
+};
+
template <typename List, template <typename> class ContinuationPredicate>
class Navigator {
public:
@@ -83,6 +91,12 @@
NavigatorStopOnNull(List& list, jfr_iter_direction direction = forward) : Navigator<List, StopOnNullCondition>(list, direction) {}
};
+template <typename List>
+class NavigatorStopOnEmpty : public Navigator<List, StopOnEmptyCondition> {
+public:
+ NavigatorStopOnEmpty(List& list, jfr_iter_direction direction = forward) : Navigator<List, StopOnEmptyCondition>(list, direction) {}
+};
+
template<typename List, template <typename> class Navigator, typename AP = StackObj>
class IteratorHost : public AP {
private:
@@ -104,4 +118,10 @@
StopOnNullIterator(List& list, jfr_iter_direction direction = forward) : IteratorHost<List, NavigatorStopOnNull, AP>(list, direction) {}
};
+template<typename List, typename AP = StackObj>
+class StopOnEmptyIterator : public IteratorHost<List, NavigatorStopOnEmpty, AP> {
+public:
+ StopOnEmptyIterator(List& list, jfr_iter_direction direction = forward) : IteratorHost<List, NavigatorStopOnEmpty, AP>(list, direction) {}
+};
+
#endif // SHARE_JFR_UTILITIES_JFRITERATOR_HPP