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

Side by Side Diff: src/v8threads.cc

Issue 6993057: Version 3.4.2 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 6 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 | « src/v8natives.js ('k') | src/version.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 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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 : Thread(isolate, "v8:CtxtSwitcher"), 404 : Thread(isolate, "v8:CtxtSwitcher"),
405 keep_going_(true), 405 keep_going_(true),
406 sleep_ms_(every_n_ms) { 406 sleep_ms_(every_n_ms) {
407 } 407 }
408 408
409 409
410 // Set the scheduling interval of V8 threads. This function starts the 410 // Set the scheduling interval of V8 threads. This function starts the
411 // ContextSwitcher thread if needed. 411 // ContextSwitcher thread if needed.
412 void ContextSwitcher::StartPreemption(int every_n_ms) { 412 void ContextSwitcher::StartPreemption(int every_n_ms) {
413 Isolate* isolate = Isolate::Current(); 413 Isolate* isolate = Isolate::Current();
414 ASSERT(Locker::IsLocked()); 414 ASSERT(Locker::IsLocked(reinterpret_cast<v8::Isolate*>(isolate)));
415 if (isolate->context_switcher() == NULL) { 415 if (isolate->context_switcher() == NULL) {
416 // If the ContextSwitcher thread is not running at the moment start it now. 416 // If the ContextSwitcher thread is not running at the moment start it now.
417 isolate->set_context_switcher(new ContextSwitcher(isolate, every_n_ms)); 417 isolate->set_context_switcher(new ContextSwitcher(isolate, every_n_ms));
418 isolate->context_switcher()->Start(); 418 isolate->context_switcher()->Start();
419 } else { 419 } else {
420 // ContextSwitcher thread is already running, so we just change the 420 // ContextSwitcher thread is already running, so we just change the
421 // scheduling interval. 421 // scheduling interval.
422 isolate->context_switcher()->sleep_ms_ = every_n_ms; 422 isolate->context_switcher()->sleep_ms_ = every_n_ms;
423 } 423 }
424 } 424 }
425 425
426 426
427 // Disable preemption of V8 threads. If multiple threads want to use V8 they 427 // Disable preemption of V8 threads. If multiple threads want to use V8 they
428 // must cooperatively schedule amongst them from this point on. 428 // must cooperatively schedule amongst them from this point on.
429 void ContextSwitcher::StopPreemption() { 429 void ContextSwitcher::StopPreemption() {
430 Isolate* isolate = Isolate::Current(); 430 Isolate* isolate = Isolate::Current();
431 ASSERT(Locker::IsLocked()); 431 ASSERT(Locker::IsLocked(reinterpret_cast<v8::Isolate*>(isolate)));
432 if (isolate->context_switcher() != NULL) { 432 if (isolate->context_switcher() != NULL) {
433 // The ContextSwitcher thread is running. We need to stop it and release 433 // The ContextSwitcher thread is running. We need to stop it and release
434 // its resources. 434 // its resources.
435 isolate->context_switcher()->keep_going_ = false; 435 isolate->context_switcher()->keep_going_ = false;
436 // Wait for the ContextSwitcher thread to exit. 436 // Wait for the ContextSwitcher thread to exit.
437 isolate->context_switcher()->Join(); 437 isolate->context_switcher()->Join();
438 // Thread has exited, now we can delete it. 438 // Thread has exited, now we can delete it.
439 delete(isolate->context_switcher()); 439 delete(isolate->context_switcher());
440 isolate->set_context_switcher(NULL); 440 isolate->set_context_switcher(NULL);
441 } 441 }
(...skipping 13 matching lines...) Expand all
455 // Acknowledge the preemption by the receiving thread. 455 // Acknowledge the preemption by the receiving thread.
456 void ContextSwitcher::PreemptionReceived() { 456 void ContextSwitcher::PreemptionReceived() {
457 ASSERT(Locker::IsLocked()); 457 ASSERT(Locker::IsLocked());
458 // There is currently no accounting being done for this. But could be in the 458 // There is currently no accounting being done for this. But could be in the
459 // future, which is why we leave this in. 459 // future, which is why we leave this in.
460 } 460 }
461 461
462 462
463 } // namespace internal 463 } // namespace internal
464 } // namespace v8 464 } // namespace v8
OLDNEW
« no previous file with comments | « src/v8natives.js ('k') | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698