OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // | 2 // |
3 // Tests of the circular queue. | 3 // Tests of the circular queue. |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 #include "circular-queue-inl.h" | 6 #include "circular-queue-inl.h" |
7 #include "cctest.h" | 7 #include "cctest.h" |
8 | 8 |
9 namespace i = v8::internal; | 9 namespace i = v8::internal; |
10 | 10 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 class ProducerThread: public i::Thread { | 83 class ProducerThread: public i::Thread { |
84 public: | 84 public: |
85 typedef SamplingCircularQueue::Cell Record; | 85 typedef SamplingCircularQueue::Cell Record; |
86 | 86 |
87 ProducerThread(i::Isolate* isolate, | 87 ProducerThread(i::Isolate* isolate, |
88 SamplingCircularQueue* scq, | 88 SamplingCircularQueue* scq, |
89 int records_per_chunk, | 89 int records_per_chunk, |
90 Record value, | 90 Record value, |
91 i::Semaphore* finished) | 91 i::Semaphore* finished) |
92 : Thread(isolate), | 92 : Thread(isolate, "producer"), |
93 scq_(scq), | 93 scq_(scq), |
94 records_per_chunk_(records_per_chunk), | 94 records_per_chunk_(records_per_chunk), |
95 value_(value), | 95 value_(value), |
96 finished_(finished) { } | 96 finished_(finished) { } |
97 | 97 |
98 virtual void Run() { | 98 virtual void Run() { |
99 for (Record i = value_; i < value_ + records_per_chunk_; ++i) { | 99 for (Record i = value_; i < value_ + records_per_chunk_; ++i) { |
100 Record* rec = reinterpret_cast<Record*>(scq_->Enqueue()); | 100 Record* rec = reinterpret_cast<Record*>(scq_->Enqueue()); |
101 CHECK_NE(NULL, rec); | 101 CHECK_NE(NULL, rec); |
102 *rec = i; | 102 *rec = i; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(*rec)); | 171 CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(*rec)); |
172 CHECK_EQ(rec, reinterpret_cast<Record*>(scq.StartDequeue())); | 172 CHECK_EQ(rec, reinterpret_cast<Record*>(scq.StartDequeue())); |
173 scq.FinishDequeue(); | 173 scq.FinishDequeue(); |
174 CHECK_NE(rec, reinterpret_cast<Record*>(scq.StartDequeue())); | 174 CHECK_NE(rec, reinterpret_cast<Record*>(scq.StartDequeue())); |
175 } | 175 } |
176 | 176 |
177 CHECK_EQ(NULL, scq.StartDequeue()); | 177 CHECK_EQ(NULL, scq.StartDequeue()); |
178 | 178 |
179 delete semaphore; | 179 delete semaphore; |
180 } | 180 } |
OLD | NEW |