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

Side by Side Diff: test/cctest/test-threads.cc

Issue 462033002: Fix newly discovered presubmit errors. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: More of the same. Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-thread-termination.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 26 matching lines...) Expand all
37 CLEAN_CACHE, 37 CLEAN_CACHE,
38 SECOND_TIME_FILL_CACHE, 38 SECOND_TIME_FILL_CACHE,
39 DONE 39 DONE
40 }; 40 };
41 41
42 static Turn turn = FILL_CACHE; 42 static Turn turn = FILL_CACHE;
43 43
44 44
45 class ThreadA : public v8::base::Thread { 45 class ThreadA : public v8::base::Thread {
46 public: 46 public:
47 ThreadA() : Thread("ThreadA") { } 47 ThreadA() : Thread(Options("ThreadA")) {}
48 void Run() { 48 void Run() {
49 v8::Isolate* isolate = CcTest::isolate(); 49 v8::Isolate* isolate = CcTest::isolate();
50 v8::Locker locker(isolate); 50 v8::Locker locker(isolate);
51 v8::Isolate::Scope isolate_scope(isolate); 51 v8::Isolate::Scope isolate_scope(isolate);
52 v8::HandleScope scope(isolate); 52 v8::HandleScope scope(isolate);
53 v8::Handle<v8::Context> context = v8::Context::New(isolate); 53 v8::Handle<v8::Context> context = v8::Context::New(isolate);
54 v8::Context::Scope context_scope(context); 54 v8::Context::Scope context_scope(context);
55 55
56 CHECK_EQ(FILL_CACHE, turn); 56 CHECK_EQ(FILL_CACHE, turn);
57 57
(...skipping 19 matching lines...) Expand all
77 // Rerun the script. 77 // Rerun the script.
78 CHECK(script->Run()->IsTrue()); 78 CHECK(script->Run()->IsTrue());
79 79
80 turn = DONE; 80 turn = DONE;
81 } 81 }
82 }; 82 };
83 83
84 84
85 class ThreadB : public v8::base::Thread { 85 class ThreadB : public v8::base::Thread {
86 public: 86 public:
87 ThreadB() : Thread("ThreadB") { } 87 ThreadB() : Thread(Options("ThreadB")) {}
88 void Run() { 88 void Run() {
89 do { 89 do {
90 { 90 {
91 v8::Isolate* isolate = CcTest::isolate(); 91 v8::Isolate* isolate = CcTest::isolate();
92 v8::Locker locker(isolate); 92 v8::Locker locker(isolate);
93 v8::Isolate::Scope isolate_scope(isolate); 93 v8::Isolate::Scope isolate_scope(isolate);
94 if (turn == CLEAN_CACHE) { 94 if (turn == CLEAN_CACHE) {
95 v8::HandleScope scope(isolate); 95 v8::HandleScope scope(isolate);
96 v8::Handle<v8::Context> context = v8::Context::New(isolate); 96 v8::Handle<v8::Context> context = v8::Context::New(isolate);
97 v8::Context::Scope context_scope(context); 97 v8::Context::Scope context_scope(context);
(...skipping 20 matching lines...) Expand all
118 118
119 threadA.Join(); 119 threadA.Join();
120 threadB.Join(); 120 threadB.Join();
121 121
122 CHECK_EQ(DONE, turn); 122 CHECK_EQ(DONE, turn);
123 } 123 }
124 124
125 class ThreadIdValidationThread : public v8::base::Thread { 125 class ThreadIdValidationThread : public v8::base::Thread {
126 public: 126 public:
127 ThreadIdValidationThread(v8::base::Thread* thread_to_start, 127 ThreadIdValidationThread(v8::base::Thread* thread_to_start,
128 i::List<i::ThreadId>* refs, 128 i::List<i::ThreadId>* refs, unsigned int thread_no,
129 unsigned int thread_no,
130 v8::base::Semaphore* semaphore) 129 v8::base::Semaphore* semaphore)
131 : Thread("ThreadRefValidationThread"), 130 : Thread(Options("ThreadRefValidationThread")),
132 refs_(refs), thread_no_(thread_no), thread_to_start_(thread_to_start), 131 refs_(refs),
133 semaphore_(semaphore) { 132 thread_no_(thread_no),
134 } 133 thread_to_start_(thread_to_start),
134 semaphore_(semaphore) {}
135 135
136 void Run() { 136 void Run() {
137 i::ThreadId thread_id = i::ThreadId::Current(); 137 i::ThreadId thread_id = i::ThreadId::Current();
138 for (int i = 0; i < thread_no_; i++) { 138 for (int i = 0; i < thread_no_; i++) {
139 CHECK(!(*refs_)[i].Equals(thread_id)); 139 CHECK(!(*refs_)[i].Equals(thread_id));
140 } 140 }
141 CHECK(thread_id.IsValid()); 141 CHECK(thread_id.IsValid());
142 (*refs_)[thread_no_] = thread_id; 142 (*refs_)[thread_no_] = thread_id;
143 if (thread_to_start_ != NULL) { 143 if (thread_to_start_ != NULL) {
144 thread_to_start_->Start(); 144 thread_to_start_->Start();
(...skipping 23 matching lines...) Expand all
168 refs.Add(i::ThreadId::Invalid()); 168 refs.Add(i::ThreadId::Invalid());
169 } 169 }
170 prev->Start(); 170 prev->Start();
171 for (int i = 0; i < kNThreads; i++) { 171 for (int i = 0; i < kNThreads; i++) {
172 semaphore.Wait(); 172 semaphore.Wait();
173 } 173 }
174 for (int i = 0; i < kNThreads; i++) { 174 for (int i = 0; i < kNThreads; i++) {
175 delete threads[i]; 175 delete threads[i];
176 } 176 }
177 } 177 }
OLDNEW
« no previous file with comments | « test/cctest/test-thread-termination.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698