Chromium Code Reviews| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 private: | 80 private: |
| 81 static void EagerlyArchiveThread(); | 81 static void EagerlyArchiveThread(); |
| 82 | 82 |
| 83 static Mutex* mutex_; | 83 static Mutex* mutex_; |
| 84 static ThreadHandle mutex_owner_; | 84 static ThreadHandle mutex_owner_; |
| 85 static ThreadHandle lazily_archived_thread_; | 85 static ThreadHandle lazily_archived_thread_; |
| 86 static ThreadState* lazily_archived_thread_state_; | 86 static ThreadState* lazily_archived_thread_state_; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 | 89 |
| 90 // The ContextSwitcher thread is used to schedule regular preemptions to | |
| 91 // multiple running V8 threads. Generally it is needed to call StartPreemption | |
|
Erik Corry
2008/12/17 14:30:07
"it is necessary"
iposva
2008/12/17 17:39:24
Done.
| |
| 92 // if there is more than one thread running. If not a single JavaScript can | |
|
Erik Corry
2008/12/17 14:30:07
"If not, a single JavaScript thread can"
iposva
2008/12/17 17:39:24
Done.
| |
| 93 // take full control of V8 and not allow other threads to run. | |
| 90 class ContextSwitcher: public Thread { | 94 class ContextSwitcher: public Thread { |
| 91 public: | 95 public: |
| 92 void Run(); | 96 // Set the preemption interval for the ContextSwitcher thread. |
| 93 static void StartPreemption(int every_n_ms); | 97 static void StartPreemption(int every_n_ms); |
| 98 | |
| 99 // Stop sending preemption requests to threads. | |
| 94 static void StopPreemption(); | 100 static void StopPreemption(); |
| 101 | |
| 102 // Preempted thread needs to calls back to the ContextSwitcher to acknowlege | |
|
Erik Corry
2008/12/17 14:30:07
"to call back"
iposva
2008/12/17 17:39:24
Done.
| |
| 103 // the handling of a preemption request. | |
| 95 static void PreemptionReceived(); | 104 static void PreemptionReceived(); |
| 105 | |
| 96 private: | 106 private: |
| 97 explicit ContextSwitcher(int every_n_ms); | 107 explicit ContextSwitcher(int every_n_ms); |
| 98 void WaitForPreemption(); | 108 |
| 99 void Stop(); | 109 void Run(); |
| 100 Semaphore* preemption_semaphore_; | 110 |
| 101 bool keep_going_; | 111 bool keep_going_; |
| 102 int sleep_ms_; | 112 int sleep_ms_; |
| 113 | |
| 114 static ContextSwitcher* singleton_; | |
| 103 }; | 115 }; |
| 104 | 116 |
| 105 } } // namespace v8::internal | 117 } } // namespace v8::internal |
| 106 | 118 |
| 107 #endif // V8_V8THREADS_H_ | 119 #endif // V8_V8THREADS_H_ |
| OLD | NEW |