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

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

Issue 484643002: Version 3.28.71.3 (merged r23081) (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.28
Patch Set: 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-libplatform.h ('k') | test/cctest/test-semaphore.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 2007-2011 the V8 project authors. All rights reserved. 1 // Copyright 2007-2011 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 using ::v8::Script; 52 using ::v8::Script;
53 using ::v8::String; 53 using ::v8::String;
54 using ::v8::Value; 54 using ::v8::Value;
55 using ::v8::V8; 55 using ::v8::V8;
56 56
57 57
58 // Migrating an isolate 58 // Migrating an isolate
59 class KangarooThread : public v8::base::Thread { 59 class KangarooThread : public v8::base::Thread {
60 public: 60 public:
61 KangarooThread(v8::Isolate* isolate, v8::Handle<v8::Context> context) 61 KangarooThread(v8::Isolate* isolate, v8::Handle<v8::Context> context)
62 : Thread("KangarooThread"), 62 : Thread(Options("KangarooThread")),
63 isolate_(isolate), 63 isolate_(isolate),
64 context_(isolate, context) {} 64 context_(isolate, context) {}
65 65
66 void Run() { 66 void Run() {
67 { 67 {
68 v8::Locker locker(isolate_); 68 v8::Locker locker(isolate_);
69 v8::Isolate::Scope isolate_scope(isolate_); 69 v8::Isolate::Scope isolate_scope(isolate_);
70 CHECK_EQ(isolate_, v8::internal::Isolate::Current()); 70 CHECK_EQ(isolate_, v8::internal::Isolate::Current());
71 v8::HandleScope scope(isolate_); 71 v8::HandleScope scope(isolate_);
72 v8::Local<v8::Context> context = 72 v8::Local<v8::Context> context =
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 void Join() { 142 void Join() {
143 semaphore_.Wait(); 143 semaphore_.Wait();
144 } 144 }
145 145
146 virtual void Run() = 0; 146 virtual void Run() = 0;
147 147
148 private: 148 private:
149 class ThreadWithSemaphore : public v8::base::Thread { 149 class ThreadWithSemaphore : public v8::base::Thread {
150 public: 150 public:
151 explicit ThreadWithSemaphore(JoinableThread* joinable_thread) 151 explicit ThreadWithSemaphore(JoinableThread* joinable_thread)
152 : Thread(joinable_thread->name_), 152 : Thread(Options(joinable_thread->name_)),
153 joinable_thread_(joinable_thread) { 153 joinable_thread_(joinable_thread) {}
154 }
155 154
156 virtual void Run() { 155 virtual void Run() {
157 joinable_thread_->Run(); 156 joinable_thread_->Run();
158 joinable_thread_->semaphore_.Signal(); 157 joinable_thread_->semaphore_.Signal();
159 } 158 }
160 159
161 private: 160 private:
162 JoinableThread* joinable_thread_; 161 JoinableThread* joinable_thread_;
163 }; 162 };
164 163
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 v8::Isolate* isolate = v8::Isolate::New(); 215 v8::Isolate* isolate = v8::Isolate::New();
217 for (int i = 0; i < kNThreads; i++) { 216 for (int i = 0; i < kNThreads; i++) {
218 threads.Add(new IsolateLockingThreadWithLocalContext(isolate)); 217 threads.Add(new IsolateLockingThreadWithLocalContext(isolate));
219 } 218 }
220 StartJoinAndDeleteThreads(threads); 219 StartJoinAndDeleteThreads(threads);
221 isolate->Dispose(); 220 isolate->Dispose();
222 } 221 }
223 222
224 class IsolateNonlockingThread : public JoinableThread { 223 class IsolateNonlockingThread : public JoinableThread {
225 public: 224 public:
226 explicit IsolateNonlockingThread() 225 IsolateNonlockingThread() : JoinableThread("IsolateNonlockingThread") {}
227 : JoinableThread("IsolateNonlockingThread") {
228 }
229 226
230 virtual void Run() { 227 virtual void Run() {
231 v8::Isolate* isolate = v8::Isolate::New(); 228 v8::Isolate* isolate = v8::Isolate::New();
232 { 229 {
233 v8::Isolate::Scope isolate_scope(isolate); 230 v8::Isolate::Scope isolate_scope(isolate);
234 v8::HandleScope handle_scope(isolate); 231 v8::HandleScope handle_scope(isolate);
235 v8::Handle<v8::Context> context = v8::Context::New(isolate); 232 v8::Handle<v8::Context> context = v8::Context::New(isolate);
236 v8::Context::Scope context_scope(context); 233 v8::Context::Scope context_scope(context);
237 CHECK_EQ(isolate, v8::internal::Isolate::Current()); 234 CHECK_EQ(isolate, v8::internal::Isolate::Current());
238 CalcFibAndCheck(); 235 CalcFibAndCheck();
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 kSimpleExtensionSource)); 735 kSimpleExtensionSource));
739 const char* extension_names[] = { "test0", "test1", 736 const char* extension_names[] = { "test0", "test1",
740 "test2", "test3", "test4", 737 "test2", "test3", "test4",
741 "test5", "test6", "test7" }; 738 "test5", "test6", "test7" };
742 i::List<JoinableThread*> threads(kNThreads); 739 i::List<JoinableThread*> threads(kNThreads);
743 for (int i = 0; i < kNThreads; i++) { 740 for (int i = 0; i < kNThreads; i++) {
744 threads.Add(new IsolateGenesisThread(8, extension_names)); 741 threads.Add(new IsolateGenesisThread(8, extension_names));
745 } 742 }
746 StartJoinAndDeleteThreads(threads); 743 StartJoinAndDeleteThreads(threads);
747 } 744 }
OLDNEW
« no previous file with comments | « test/cctest/test-libplatform.h ('k') | test/cctest/test-semaphore.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698