Index: src/circular-queue-inl.h |
diff --git a/src/circular-queue-inl.h b/src/circular-queue-inl.h |
index 373bf6092a95f40e7aaa01bb835436b312bf2703..b48070ab5d24a064e4f8a91a72020e80d8f02954 100644 |
--- a/src/circular-queue-inl.h |
+++ b/src/circular-queue-inl.h |
@@ -35,7 +35,16 @@ namespace internal { |
void* SamplingCircularQueue::Enqueue() { |
- WrapPositionIfNeeded(&producer_pos_->enqueue_pos); |
+ if (producer_pos_->enqueue_pos == producer_pos_->next_chunk_pos) { |
+ if (producer_pos_->enqueue_pos == buffer_ + buffer_size_) { |
+ producer_pos_->next_chunk_pos = buffer_; |
+ producer_pos_->enqueue_pos = buffer_; |
+ } |
+ Acquire_Store(producer_pos_->next_chunk_pos, kEnqueueStarted); |
+ // Skip marker. |
+ producer_pos_->enqueue_pos += 1; |
+ producer_pos_->next_chunk_pos += chunk_size_; |
+ } |
void* result = producer_pos_->enqueue_pos; |
producer_pos_->enqueue_pos += record_size_; |
return result; |
@@ -44,7 +53,7 @@ void* SamplingCircularQueue::Enqueue() { |
void SamplingCircularQueue::WrapPositionIfNeeded( |
SamplingCircularQueue::Cell** pos) { |
- if (**pos == kEnd) *pos = buffer_; |
+ if (*pos == buffer_ + buffer_size_) *pos = buffer_; |
} |