Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/jfr/utilities/jfrConcurrentQueue.inline.hpp
41149 views
1
/*
2
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
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_JFR_UTILITIES_JFRCONCURRENTQUEUE_INLINE_HPP
26
#define SHARE_JFR_UTILITIES_JFRCONCURRENTQUEUE_INLINE_HPP
27
28
#include "jfr/utilities/jfrConcurrentQueue.hpp"
29
30
#include "jfr/utilities/jfrConcurrentLinkedListHost.inline.hpp"
31
#include "jfr/utilities/jfrVersionSystem.inline.hpp"
32
33
template <typename NodeType, typename AllocPolicy>
34
JfrConcurrentQueue<NodeType, AllocPolicy>::JfrConcurrentQueue() : _list(NULL), _head(), _last(), _tail(), _version_system() {
35
_head._next = const_cast<NodePtr>(&_tail);
36
_last._next = const_cast<NodePtr>(&_tail);
37
}
38
39
template <typename NodeType, typename AllocPolicy>
40
bool JfrConcurrentQueue<NodeType, AllocPolicy>::initialize() {
41
assert(_list == NULL, "invariant");
42
_list = new JfrConcurrentLinkedListHost<JfrConcurrentQueue<NodeType, AllocPolicy>, HeadNode, AllocPolicy>(this);
43
return _list != NULL && _list->initialize();
44
}
45
46
template <typename NodeType, typename AllocPolicy>
47
inline bool JfrConcurrentQueue<NodeType, AllocPolicy>::is_empty() const {
48
return Atomic::load_acquire(&_head._next) == &_tail;
49
}
50
51
template <typename NodeType, typename AllocPolicy>
52
inline bool JfrConcurrentQueue<NodeType, AllocPolicy>::is_nonempty() const {
53
return !is_empty();
54
}
55
56
template <typename NodeType, typename AllocPolicy>
57
void JfrConcurrentQueue<NodeType, AllocPolicy>::add(typename JfrConcurrentQueue<NodeType, AllocPolicy>::NodePtr node) {
58
_list->insert_tail(node, &_head, &_last, &_tail);
59
}
60
61
template <typename NodeType, typename AllocPolicy>
62
typename JfrConcurrentQueue<NodeType, AllocPolicy>::NodePtr JfrConcurrentQueue<NodeType, AllocPolicy>::remove() {
63
return _list->remove(&_head, &_tail, &_last, false);
64
}
65
66
template <typename NodeType, typename AllocPolicy>
67
template <typename Callback>
68
void JfrConcurrentQueue<NodeType, AllocPolicy>::iterate(Callback& cb) {
69
_list->iterate(&_head, &_tail, cb);
70
}
71
72
template <typename NodeType, typename AllocPolicy>
73
inline JfrVersionSystem::Handle JfrConcurrentQueue<NodeType, AllocPolicy>::get_version_handle() {
74
return _version_system.get();
75
}
76
77
template <typename NodeType, typename AllocPolicy>
78
bool JfrConcurrentQueue<NodeType, AllocPolicy>::in_list(const NodeType* node) const {
79
assert(node != NULL, "invariant");
80
return _list->in_list(node, const_cast<NodePtr>(&_head), &_tail);
81
}
82
83
#endif // SHARE_JFR_UTILITIES_JFRCONCURRENTQUEUE_INLINE_HPP
84
85