5 #ifndef V8_PROFILER_UNBOUND_QUEUE_INL_H_ 6 #define V8_PROFILER_UNBOUND_QUEUE_INL_H_ 8 #include "src/profiler/unbound-queue.h" 13 template<
typename Record>
15 explicit Node(
const Record& value) : value(value), next(
nullptr) {}
22 template<
typename Record>
24 first_ =
new Node(Record());
25 divider_ = last_ =
reinterpret_cast<base::AtomicWord
>(first_);
29 template<
typename Record>
31 while (first_ !=
nullptr) DeleteFirst();
35 template<
typename Record>
36 void UnboundQueue<Record>::DeleteFirst() {
43 template<
typename Record>
44 bool UnboundQueue<Record>::Dequeue(Record* rec) {
45 if (divider_ == base::Acquire_Load(&last_))
return false;
46 Node* next =
reinterpret_cast<Node*
>(divider_)->next;
48 base::Release_Store(÷r_, reinterpret_cast<base::AtomicWord>(next));
53 template<
typename Record>
54 void UnboundQueue<Record>::Enqueue(
const Record& rec) {
55 Node*& next =
reinterpret_cast<Node*
>(last_)->next;
57 base::Release_Store(&last_, reinterpret_cast<base::AtomicWord>(next));
59 while (first_ != reinterpret_cast<Node*>(base::Acquire_Load(÷r_))) {
65 template<
typename Record>
66 bool UnboundQueue<Record>::IsEmpty()
const {
67 return base::Relaxed_Load(÷r_) == base::Relaxed_Load(&last_);
71 template<
typename Record>
72 Record* UnboundQueue<Record>::Peek()
const {
73 if (divider_ == base::Acquire_Load(&last_))
return nullptr;
74 Node* next =
reinterpret_cast<Node*
>(divider_)->next;
81 #endif // V8_PROFILER_UNBOUND_QUEUE_INL_H_