Revision: 16549
Author:   yu...@chromium.org
Date:     Thu Sep  5 10:31:18 2013 UTC
Log:      Rename some of SamplingCircularQueue methods

Renamed StartDequeue -> Peek, FinishDequeue -> Remove.

BUG=None
R=bmeu...@chromium.org, loi...@chromium.org

Review URL: https://codereview.chromium.org/23686006
http://code.google.com/p/v8/source/detail?r=16549

Modified:
 /branches/bleeding_edge/src/circular-queue-inl.h
 /branches/bleeding_edge/src/circular-queue.h
 /branches/bleeding_edge/src/cpu-profiler.cc
 /branches/bleeding_edge/test/cctest/test-circular-queue.cc

=======================================
--- /branches/bleeding_edge/src/circular-queue-inl.h Fri Aug 23 08:22:07 2013 UTC +++ /branches/bleeding_edge/src/circular-queue-inl.h Thu Sep 5 10:31:18 2013 UTC
@@ -46,7 +46,7 @@


 template<typename T, unsigned L>
-T* SamplingCircularQueue<T, L>::StartDequeue() {
+T* SamplingCircularQueue<T, L>::Peek() {
   MemoryBarrier();
   if (Acquire_Load(&dequeue_pos_->marker) == kFull) {
     return &dequeue_pos_->record;
@@ -56,7 +56,7 @@


 template<typename T, unsigned L>
-void SamplingCircularQueue<T, L>::FinishDequeue() {
+void SamplingCircularQueue<T, L>::Remove() {
   Release_Store(&dequeue_pos_->marker, kEmpty);
   dequeue_pos_ = Next(dequeue_pos_);
 }
=======================================
--- /branches/bleeding_edge/src/circular-queue.h Mon Aug 26 11:18:28 2013 UTC +++ /branches/bleeding_edge/src/circular-queue.h Thu Sep 5 10:31:18 2013 UTC
@@ -55,12 +55,11 @@
   void FinishEnqueue();

   // Executed on the consumer (analyzer) thread.
-  // 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
-  // to StartDequeue will return the same pointer.
-  T* StartDequeue();
-  void FinishDequeue();
+  // Retrieves, but does not remove, the head of this queue, returning NULL
+  // if this queue is empty. After the record had been read by a consumer,
+  // Remove must be called.
+  T* Peek();
+  void Remove();

  private:
   // Reserved values for the entry marker.
=======================================
--- /branches/bleeding_edge/src/cpu-profiler.cc Thu Sep  5 10:28:57 2013 UTC
+++ /branches/bleeding_edge/src/cpu-profiler.cc Thu Sep  5 10:31:18 2013 UTC
@@ -114,11 +114,11 @@
     return false;
   }

-  const TickSampleEventRecord* record = ticks_buffer_.StartDequeue();
+  const TickSampleEventRecord* record = ticks_buffer_.Peek();
   if (record == NULL) return true;
   if (record->order != last_processed_code_event_id_) return true;
   generator_->RecordTickSample(record->sample);
-  ticks_buffer_.FinishDequeue();
+  ticks_buffer_.Remove();
   return false;
 }

=======================================
--- /branches/bleeding_edge/test/cctest/test-circular-queue.cc Mon Sep 2 12:26:06 2013 UTC +++ /branches/bleeding_edge/test/cctest/test-circular-queue.cc Thu Sep 5 10:31:18 2013 UTC
@@ -41,7 +41,7 @@

   // Check that we are using non-reserved values.
   // Fill up the first chunk.
-  CHECK_EQ(NULL, scq.StartDequeue());
+  CHECK_EQ(NULL, scq.Peek());
   for (Record i = 1; i < 1 + kMaxRecordsInQueue; ++i) {
     Record* rec = reinterpret_cast<Record*>(scq.StartEnqueue());
     CHECK_NE(NULL, rec);
@@ -53,27 +53,27 @@
   CHECK_EQ(NULL, scq.StartEnqueue());

// Try to enqueue when the the queue is full. Consumption must be available.
-  CHECK_NE(NULL, scq.StartDequeue());
+  CHECK_NE(NULL, scq.Peek());
   for (int i = 0; i < 10; ++i) {
     Record* rec = reinterpret_cast<Record*>(scq.StartEnqueue());
     CHECK_EQ(NULL, rec);
-    CHECK_NE(NULL, scq.StartDequeue());
+    CHECK_NE(NULL, scq.Peek());
   }

   // Consume all records.
   for (Record i = 1; i < 1 + kMaxRecordsInQueue; ++i) {
-    Record* rec = reinterpret_cast<Record*>(scq.StartDequeue());
+    Record* rec = reinterpret_cast<Record*>(scq.Peek());
     CHECK_NE(NULL, rec);
     CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(*rec));
-    CHECK_EQ(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
-    scq.FinishDequeue();
-    CHECK_NE(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
+    CHECK_EQ(rec, reinterpret_cast<Record*>(scq.Peek()));
+    scq.Remove();
+    CHECK_NE(rec, reinterpret_cast<Record*>(scq.Peek()));
   }
   // The queue is empty.
-  CHECK_EQ(NULL, scq.StartDequeue());
+  CHECK_EQ(NULL, scq.Peek());


-  CHECK_EQ(NULL, scq.StartDequeue());
+  CHECK_EQ(NULL, scq.Peek());
   for (Record i = 0; i < kMaxRecordsInQueue / 2; ++i) {
     Record* rec = reinterpret_cast<Record*>(scq.StartEnqueue());
     CHECK_NE(NULL, rec);
@@ -82,18 +82,18 @@
   }

   // Consume all available kMaxRecordsInQueue / 2 records.
-  CHECK_NE(NULL, scq.StartDequeue());
+  CHECK_NE(NULL, scq.Peek());
   for (Record i = 0; i < kMaxRecordsInQueue / 2; ++i) {
-    Record* rec = reinterpret_cast<Record*>(scq.StartDequeue());
+    Record* rec = reinterpret_cast<Record*>(scq.Peek());
     CHECK_NE(NULL, rec);
     CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(*rec));
-    CHECK_EQ(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
-    scq.FinishDequeue();
-    CHECK_NE(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
+    CHECK_EQ(rec, reinterpret_cast<Record*>(scq.Peek()));
+    scq.Remove();
+    CHECK_NE(rec, reinterpret_cast<Record*>(scq.Peek()));
   }

   // The queue is empty.
-  CHECK_EQ(NULL, scq.StartDequeue());
+  CHECK_EQ(NULL, scq.Peek());
 }


@@ -148,41 +148,41 @@
   ProducerThread producer2(&scq, kRecordsPerChunk, 10, &semaphore);
   ProducerThread producer3(&scq, kRecordsPerChunk, 20, &semaphore);

-  CHECK_EQ(NULL, scq.StartDequeue());
+  CHECK_EQ(NULL, scq.Peek());
   producer1.Start();
   semaphore.Wait();
   for (Record i = 1; i < 1 + kRecordsPerChunk; ++i) {
-    Record* rec = reinterpret_cast<Record*>(scq.StartDequeue());
+    Record* rec = reinterpret_cast<Record*>(scq.Peek());
     CHECK_NE(NULL, rec);
     CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(*rec));
-    CHECK_EQ(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
-    scq.FinishDequeue();
-    CHECK_NE(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
+    CHECK_EQ(rec, reinterpret_cast<Record*>(scq.Peek()));
+    scq.Remove();
+    CHECK_NE(rec, reinterpret_cast<Record*>(scq.Peek()));
   }

-  CHECK_EQ(NULL, scq.StartDequeue());
+  CHECK_EQ(NULL, scq.Peek());
   producer2.Start();
   semaphore.Wait();
   for (Record i = 10; i < 10 + kRecordsPerChunk; ++i) {
-    Record* rec = reinterpret_cast<Record*>(scq.StartDequeue());
+    Record* rec = reinterpret_cast<Record*>(scq.Peek());
     CHECK_NE(NULL, rec);
     CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(*rec));
-    CHECK_EQ(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
-    scq.FinishDequeue();
-    CHECK_NE(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
+    CHECK_EQ(rec, reinterpret_cast<Record*>(scq.Peek()));
+    scq.Remove();
+    CHECK_NE(rec, reinterpret_cast<Record*>(scq.Peek()));
   }

-  CHECK_EQ(NULL, scq.StartDequeue());
+  CHECK_EQ(NULL, scq.Peek());
   producer3.Start();
   semaphore.Wait();
   for (Record i = 20; i < 20 + kRecordsPerChunk; ++i) {
-    Record* rec = reinterpret_cast<Record*>(scq.StartDequeue());
+    Record* rec = reinterpret_cast<Record*>(scq.Peek());
     CHECK_NE(NULL, rec);
     CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(*rec));
-    CHECK_EQ(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
-    scq.FinishDequeue();
-    CHECK_NE(rec, reinterpret_cast<Record*>(scq.StartDequeue()));
+    CHECK_EQ(rec, reinterpret_cast<Record*>(scq.Peek()));
+    scq.Remove();
+    CHECK_NE(rec, reinterpret_cast<Record*>(scq.Peek()));
   }

-  CHECK_EQ(NULL, scq.StartDequeue());
+  CHECK_EQ(NULL, scq.Peek());
 }

--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to