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

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

Issue 7754022: Fix presubmit errors caused by updated depot tools (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 3 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-lockers.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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 for (int i = 0; i < thread_no_; i++) { 154 for (int i = 0; i < thread_no_; i++) {
155 CHECK(!(*refs_)[i].Equals(thread_id)); 155 CHECK(!(*refs_)[i].Equals(thread_id));
156 } 156 }
157 CHECK(thread_id.IsValid()); 157 CHECK(thread_id.IsValid());
158 (*refs_)[thread_no_] = thread_id; 158 (*refs_)[thread_no_] = thread_id;
159 if (thread_to_start_ != NULL) { 159 if (thread_to_start_ != NULL) {
160 thread_to_start_->Start(); 160 thread_to_start_->Start();
161 } 161 }
162 semaphore_->Signal(); 162 semaphore_->Signal();
163 } 163 }
164
164 private: 165 private:
165 i::List<i::ThreadId>* refs_; 166 i::List<i::ThreadId>* refs_;
166 int thread_no_; 167 int thread_no_;
167 i::Thread* thread_to_start_; 168 i::Thread* thread_to_start_;
168 i::Semaphore* semaphore_; 169 i::Semaphore* semaphore_;
169 }; 170 };
170 171
171 TEST(ThreadIdValidation) { 172 TEST(ThreadIdValidation) {
172 const int kNThreads = 100; 173 const int kNThreads = 100;
173 i::List<ThreadIdValidationThread*> threads(kNThreads); 174 i::List<ThreadIdValidationThread*> threads(kNThreads);
174 i::List<i::ThreadId> refs(kNThreads); 175 i::List<i::ThreadId> refs(kNThreads);
175 i::Semaphore* semaphore = i::OS::CreateSemaphore(0); 176 i::Semaphore* semaphore = i::OS::CreateSemaphore(0);
176 ThreadIdValidationThread* prev = NULL; 177 ThreadIdValidationThread* prev = NULL;
177 for (int i = kNThreads - 1; i >= 0; i--) { 178 for (int i = kNThreads - 1; i >= 0; i--) {
178 ThreadIdValidationThread* newThread = 179 ThreadIdValidationThread* newThread =
179 new ThreadIdValidationThread(prev, &refs, i, semaphore); 180 new ThreadIdValidationThread(prev, &refs, i, semaphore);
180 threads.Add(newThread); 181 threads.Add(newThread);
181 prev = newThread; 182 prev = newThread;
182 refs.Add(i::ThreadId::Invalid()); 183 refs.Add(i::ThreadId::Invalid());
183 } 184 }
184 prev->Start(); 185 prev->Start();
185 for (int i = 0; i < kNThreads; i++) { 186 for (int i = 0; i < kNThreads; i++) {
186 semaphore->Wait(); 187 semaphore->Wait();
187 } 188 }
188 for (int i = 0; i < kNThreads; i++) { 189 for (int i = 0; i < kNThreads; i++) {
189 delete threads[i]; 190 delete threads[i];
190 } 191 }
191 } 192 }
OLDNEW
« no previous file with comments | « test/cctest/test-lockers.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698