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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 } | 373 } |
374 } | 374 } |
375 | 375 |
376 | 376 |
377 // This is the ContextSwitcher singleton. There is at most a single thread | 377 // This is the ContextSwitcher singleton. There is at most a single thread |
378 // running which delivers preemption events to V8 threads. | 378 // running which delivers preemption events to V8 threads. |
379 ContextSwitcher* ContextSwitcher::singleton_ = NULL; | 379 ContextSwitcher* ContextSwitcher::singleton_ = NULL; |
380 | 380 |
381 | 381 |
382 ContextSwitcher::ContextSwitcher(int every_n_ms) | 382 ContextSwitcher::ContextSwitcher(int every_n_ms) |
383 : keep_going_(true), | 383 : Thread("v8:CtxtSwitcher"), |
| 384 keep_going_(true), |
384 sleep_ms_(every_n_ms) { | 385 sleep_ms_(every_n_ms) { |
385 } | 386 } |
386 | 387 |
387 | 388 |
388 // Set the scheduling interval of V8 threads. This function starts the | 389 // Set the scheduling interval of V8 threads. This function starts the |
389 // ContextSwitcher thread if needed. | 390 // ContextSwitcher thread if needed. |
390 void ContextSwitcher::StartPreemption(int every_n_ms) { | 391 void ContextSwitcher::StartPreemption(int every_n_ms) { |
391 ASSERT(Locker::IsLocked()); | 392 ASSERT(Locker::IsLocked()); |
392 if (singleton_ == NULL) { | 393 if (singleton_ == NULL) { |
393 // If the ContextSwitcher thread is not running at the moment start it now. | 394 // If the ContextSwitcher thread is not running at the moment start it now. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 // Acknowledge the preemption by the receiving thread. | 431 // Acknowledge the preemption by the receiving thread. |
431 void ContextSwitcher::PreemptionReceived() { | 432 void ContextSwitcher::PreemptionReceived() { |
432 ASSERT(Locker::IsLocked()); | 433 ASSERT(Locker::IsLocked()); |
433 // There is currently no accounting being done for this. But could be in the | 434 // There is currently no accounting being done for this. But could be in the |
434 // future, which is why we leave this in. | 435 // future, which is why we leave this in. |
435 } | 436 } |
436 | 437 |
437 | 438 |
438 } // namespace internal | 439 } // namespace internal |
439 } // namespace v8 | 440 } // namespace v8 |
OLD | NEW |