| OLD | NEW |
| 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 for (ThreadState* state = FirstThreadStateInUse(); | 399 for (ThreadState* state = FirstThreadStateInUse(); |
| 400 state != NULL; | 400 state != NULL; |
| 401 state = state->Next()) { | 401 state = state->Next()) { |
| 402 if (thread_id == state->id()) { | 402 if (thread_id == state->id()) { |
| 403 state->set_terminate_on_restore(true); | 403 state->set_terminate_on_restore(true); |
| 404 } | 404 } |
| 405 } | 405 } |
| 406 } | 406 } |
| 407 | 407 |
| 408 | 408 |
| 409 // This is the ContextSwitcher singleton. There is at most a single thread | |
| 410 // running which delivers preemption events to V8 threads. | |
| 411 ContextSwitcher* ContextSwitcher::singleton_ = NULL; | |
| 412 | |
| 413 | |
| 414 ContextSwitcher::ContextSwitcher(Isolate* isolate, int every_n_ms) | 409 ContextSwitcher::ContextSwitcher(Isolate* isolate, int every_n_ms) |
| 415 : Thread(isolate), | 410 : Thread(isolate), |
| 416 keep_going_(true), | 411 keep_going_(true), |
| 417 sleep_ms_(every_n_ms) { | 412 sleep_ms_(every_n_ms) { |
| 418 } | 413 } |
| 419 | 414 |
| 420 | 415 |
| 421 // Set the scheduling interval of V8 threads. This function starts the | 416 // Set the scheduling interval of V8 threads. This function starts the |
| 422 // ContextSwitcher thread if needed. | 417 // ContextSwitcher thread if needed. |
| 423 void ContextSwitcher::StartPreemption(int every_n_ms) { | 418 void ContextSwitcher::StartPreemption(int every_n_ms) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 // Acknowledge the preemption by the receiving thread. | 461 // Acknowledge the preemption by the receiving thread. |
| 467 void ContextSwitcher::PreemptionReceived() { | 462 void ContextSwitcher::PreemptionReceived() { |
| 468 ASSERT(Locker::IsLocked()); | 463 ASSERT(Locker::IsLocked()); |
| 469 // There is currently no accounting being done for this. But could be in the | 464 // There is currently no accounting being done for this. But could be in the |
| 470 // future, which is why we leave this in. | 465 // future, which is why we leave this in. |
| 471 } | 466 } |
| 472 | 467 |
| 473 | 468 |
| 474 } // namespace internal | 469 } // namespace internal |
| 475 } // namespace v8 | 470 } // namespace v8 |
| OLD | NEW |