Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Unified Diff: src/circular-queue.h

Issue 1138004: Add multithreading test for SamplingCircularQueue, fix implementation. (Closed)
Patch Set: Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/circular-queue.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/circular-queue.h
diff --git a/src/circular-queue.h b/src/circular-queue.h
index 11159e0388edc1d5fdfff922904d5b083a29dcd1..dce7fc2ad943b2fe603c59b1f4aab5b18af9edc3 100644
--- a/src/circular-queue.h
+++ b/src/circular-queue.h
@@ -76,15 +76,11 @@ class SamplingCircularQueue {
int buffer_size_in_chunks);
~SamplingCircularQueue();
- // Executed on the producer (sampler) or application thread.
- void SetUpProducer();
// Enqueue returns a pointer to a memory location for storing the next
// record.
INLINE(void* Enqueue());
- void TearDownProducer();
// Executed on the consumer (analyzer) thread.
- void SetUpConsumer();
// StartDequeue returns a pointer to a memory location for retrieving
// the next record. After the record had been read by a consumer,
// FinishDequeue must be called. Until that moment, subsequent calls
@@ -95,7 +91,6 @@ class SamplingCircularQueue {
// the queue must be notified whether producing has been finished in order
// to process remaining records from the buffer.
void FlushResidualRecords();
- void TearDownConsumer();
typedef AtomicWord Cell;
// Reserved values for the first cell of a record.
@@ -103,6 +98,9 @@ class SamplingCircularQueue {
static const Cell kEnd = -1; // Marks the end of the buffer.
private:
+ struct ProducerPosition {
+ Cell* enqueue_pos;
+ };
struct ConsumerPosition {
Cell* dequeue_chunk_pos;
Cell* dequeue_chunk_poll_pos;
@@ -118,10 +116,9 @@ class SamplingCircularQueue {
const int buffer_size_;
const int producer_consumer_distance_;
Cell* buffer_;
- // Store producer and consumer data in TLS to avoid modifying the
- // same CPU cache line from two threads simultaneously.
- Thread::LocalStorageKey consumer_key_;
- Thread::LocalStorageKey producer_key_;
+ byte* positions_;
+ ProducerPosition* producer_pos_;
+ ConsumerPosition* consumer_pos_;
};
« no previous file with comments | « no previous file | src/circular-queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698