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

Side by Side Diff: test/cctest/test-circular-queue.cc

Issue 6711068: Use v8::internal threading support in samples/shell.cc. (Closed)
Patch Set: Created 9 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 unified diff | Download patch
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698