5 #ifndef V8_PROFILER_CIRCULAR_QUEUE_INL_H_ 6 #define V8_PROFILER_CIRCULAR_QUEUE_INL_H_ 8 #include "src/profiler/circular-queue.h" 13 template<
typename T,
unsigned L>
14 SamplingCircularQueue<T, L>::SamplingCircularQueue()
15 : enqueue_pos_(buffer_),
16 dequeue_pos_(buffer_) {
19 template <
typename T,
unsigned L>
20 SamplingCircularQueue<T, L>::~SamplingCircularQueue() =
default;
22 template<
typename T,
unsigned L>
23 T* SamplingCircularQueue<T, L>::Peek() {
24 base::SeqCst_MemoryFence();
25 if (base::Acquire_Load(&dequeue_pos_->marker) == kFull) {
26 return &dequeue_pos_->record;
32 template<
typename T,
unsigned L>
33 void SamplingCircularQueue<T, L>::Remove() {
34 base::Release_Store(&dequeue_pos_->marker, kEmpty);
35 dequeue_pos_ = Next(dequeue_pos_);
39 template<
typename T,
unsigned L>
40 T* SamplingCircularQueue<T, L>::StartEnqueue() {
41 base::SeqCst_MemoryFence();
42 if (base::Acquire_Load(&enqueue_pos_->marker) == kEmpty) {
43 return &enqueue_pos_->record;
49 template<
typename T,
unsigned L>
50 void SamplingCircularQueue<T, L>::FinishEnqueue() {
51 base::Release_Store(&enqueue_pos_->marker, kFull);
52 enqueue_pos_ = Next(enqueue_pos_);
56 template<
typename T,
unsigned L>
57 typename SamplingCircularQueue<T, L>::Entry* SamplingCircularQueue<T, L>::Next(
59 Entry* next = entry + 1;
60 if (next == &buffer_[L])
return buffer_;
67 #endif // V8_PROFILER_CIRCULAR_QUEUE_INL_H_