OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // Head of linked list of states in use. | 132 // Head of linked list of states in use. |
133 ThreadState* in_use_anchor_; | 133 ThreadState* in_use_anchor_; |
134 | 134 |
135 Isolate* isolate_; | 135 Isolate* isolate_; |
136 | 136 |
137 friend class Isolate; | 137 friend class Isolate; |
138 friend class ThreadState; | 138 friend class ThreadState; |
139 }; | 139 }; |
140 | 140 |
141 | 141 |
142 // The ContextSwitcher thread is used to schedule regular preemptions to | |
143 // multiple running V8 threads. Generally it is necessary to call | |
144 // StartPreemption if there is more than one thread running. If not, a single | |
145 // JavaScript can take full control of V8 and not allow other threads to run. | |
146 class ContextSwitcher: public Thread { | |
147 public: | |
148 // Set the preemption interval for the ContextSwitcher thread. | |
149 static void StartPreemption(Isolate* isolate, int every_n_ms); | |
150 | |
151 // Stop sending preemption requests to threads. | |
152 static void StopPreemption(Isolate* isolate); | |
153 | |
154 // Preempted thread needs to call back to the ContextSwitcher to acknowledge | |
155 // the handling of a preemption request. | |
156 static void PreemptionReceived(); | |
157 | |
158 private: | |
159 ContextSwitcher(Isolate* isolate, int every_n_ms); | |
160 | |
161 Isolate* isolate() const { return isolate_; } | |
162 | |
163 void Run(); | |
164 | |
165 bool keep_going_; | |
166 int sleep_ms_; | |
167 Isolate* isolate_; | |
168 }; | |
169 | |
170 } } // namespace v8::internal | 142 } } // namespace v8::internal |
171 | 143 |
172 #endif // V8_V8THREADS_H_ | 144 #endif // V8_V8THREADS_H_ |
OLD | NEW |