| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 // StartPreemption if there is more than one thread running. If not, a single | 92 // StartPreemption if there is more than one thread running. If not, a single |
| 93 // JavaScript can take full control of V8 and not allow other threads to run. | 93 // JavaScript can take full control of V8 and not allow other threads to run. |
| 94 class ContextSwitcher: public Thread { | 94 class ContextSwitcher: public Thread { |
| 95 public: | 95 public: |
| 96 // Set the preemption interval for the ContextSwitcher thread. | 96 // Set the preemption interval for the ContextSwitcher thread. |
| 97 static void StartPreemption(int every_n_ms); | 97 static void StartPreemption(int every_n_ms); |
| 98 | 98 |
| 99 // Stop sending preemption requests to threads. | 99 // Stop sending preemption requests to threads. |
| 100 static void StopPreemption(); | 100 static void StopPreemption(); |
| 101 | 101 |
| 102 // Preempted thread needs to call back to the ContextSwitcher to acknowlege | 102 // Preempted thread needs to call back to the ContextSwitcher to acknowledge |
| 103 // the handling of a preemption request. | 103 // the handling of a preemption request. |
| 104 static void PreemptionReceived(); | 104 static void PreemptionReceived(); |
| 105 | 105 |
| 106 private: | 106 private: |
| 107 explicit ContextSwitcher(int every_n_ms); | 107 explicit ContextSwitcher(int every_n_ms); |
| 108 | 108 |
| 109 void Run(); | 109 void Run(); |
| 110 | 110 |
| 111 bool keep_going_; | 111 bool keep_going_; |
| 112 int sleep_ms_; | 112 int sleep_ms_; |
| 113 | 113 |
| 114 static ContextSwitcher* singleton_; | 114 static ContextSwitcher* singleton_; |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 } } // namespace v8::internal | 117 } } // namespace v8::internal |
| 118 | 118 |
| 119 #endif // V8_V8THREADS_H_ | 119 #endif // V8_V8THREADS_H_ |
| OLD | NEW |