Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/jfr/utilities/jfrConcurrentQueue.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_HPP
26
#define SHARE_JFR_UTILITIES_JFRCONCURRENTQUEUE_HPP
27
28
#include "jfr/utilities/jfrAllocation.hpp"
29
#include "jfr/utilities/jfrConcurrentLinkedListHost.hpp"
30
#include "jfr/utilities/jfrRelation.hpp"
31
#include "jfr/utilities/jfrVersionSystem.hpp"
32
33
/*
34
* This is a thread-safe FIFO structure.
35
* Although not non-blocking, for certain scenarios,
36
* it can act as a close approximation, "mostly" concurrent.
37
* For a more detailed description of its properties,
38
* please see JfrConcurrentLinkedListHost.hpp.
39
*/
40
template <typename NodeType, typename AllocPolicy = JfrCHeapObj>
41
class JfrConcurrentQueue : public AllocPolicy {
42
public:
43
typedef NodeType Node;
44
typedef NodeType* NodePtr;
45
typedef const NodeType* ConstNodePtr;
46
typedef JfrVersionSystem VersionSystem;
47
JfrConcurrentQueue();
48
bool initialize();
49
bool is_empty() const;
50
bool is_nonempty() const;
51
void add(NodePtr node);
52
NodePtr remove();
53
template <typename Callback>
54
void iterate(Callback& cb);
55
bool in_list(const Node* node) const;
56
private:
57
JfrConcurrentLinkedListHost<JfrConcurrentQueue<Node, AllocPolicy>, HeadNode>* _list;
58
Node _head;
59
Node _last;
60
const Node _tail;
61
JfrVersionSystem _version_system;
62
// callback for JfrConcurrentLinkedListHost
63
typename VersionSystem::Handle get_version_handle();
64
template <typename, template <typename> class, typename>
65
friend class JfrConcurrentLinkedListHost;
66
};
67
68
#endif // SHARE_JFR_UTILITIES_JFRCONCURRENTQUEUE_HPP
69
70
71