OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // Called on the main thread. | 102 // Called on the main thread. |
103 void start(std::unique_ptr<WorkerThreadStartupData>); | 103 void start(std::unique_ptr<WorkerThreadStartupData>); |
104 void terminate(); | 104 void terminate(); |
105 | 105 |
106 // Called on the main thread. Internally calls terminateInternal() and wait | 106 // Called on the main thread. Internally calls terminateInternal() and wait |
107 // (by *blocking* the calling thread) until the worker(s) is/are shut down. | 107 // (by *blocking* the calling thread) until the worker(s) is/are shut down. |
108 void terminateAndWait(); | 108 void terminateAndWait(); |
109 static void terminateAndWaitForAllWorkers(); | 109 static void terminateAndWaitForAllWorkers(); |
110 | 110 |
111 virtual WorkerBackingThread& workerBackingThread() = 0; | 111 virtual WorkerBackingThread& workerBackingThread() = 0; |
112 virtual ConsoleMessageStorage* consoleMessageStorage() = 0; | 112 ConsoleMessageStorage* consoleMessageStorage() const { return m_consoleMessa
geStorage.get(); } |
113 virtual bool shouldAttachThreadDebugger() const { return true; } | 113 virtual bool shouldAttachThreadDebugger() const { return true; } |
114 v8::Isolate* isolate(); | 114 v8::Isolate* isolate(); |
115 | 115 |
116 // Can be used to wait for this worker thread to terminate. | 116 // Can be used to wait for this worker thread to terminate. |
117 // (This is signaled on the main thread, so it's assumed to be waited on | 117 // (This is signaled on the main thread, so it's assumed to be waited on |
118 // the worker context thread) | 118 // the worker context thread) |
119 WaitableEvent* terminationEvent() { return m_terminationEvent.get(); } | 119 WaitableEvent* terminationEvent() { return m_terminationEvent.get(); } |
120 | 120 |
121 bool isCurrentThread(); | 121 bool isCurrentThread(); |
122 | 122 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 std::unique_ptr<InspectorTaskRunner> m_inspectorTaskRunner; | 231 std::unique_ptr<InspectorTaskRunner> m_inspectorTaskRunner; |
232 std::unique_ptr<WorkerMicrotaskRunner> m_microtaskRunner; | 232 std::unique_ptr<WorkerMicrotaskRunner> m_microtaskRunner; |
233 | 233 |
234 RefPtr<WorkerLoaderProxy> m_workerLoaderProxy; | 234 RefPtr<WorkerLoaderProxy> m_workerLoaderProxy; |
235 WorkerReportingProxy& m_workerReportingProxy; | 235 WorkerReportingProxy& m_workerReportingProxy; |
236 | 236 |
237 // This lock protects |m_globalScope|, |m_terminated|, |m_readyToShutdown|, | 237 // This lock protects |m_globalScope|, |m_terminated|, |m_readyToShutdown|, |
238 // |m_runningDebuggerTask|, |m_exitCode| and |m_microtaskRunner|. | 238 // |m_runningDebuggerTask|, |m_exitCode| and |m_microtaskRunner|. |
239 Mutex m_threadStateMutex; | 239 Mutex m_threadStateMutex; |
240 | 240 |
| 241 Persistent<ConsoleMessageStorage> m_consoleMessageStorage; |
241 Persistent<WorkerOrWorkletGlobalScope> m_globalScope; | 242 Persistent<WorkerOrWorkletGlobalScope> m_globalScope; |
242 Persistent<WorkerInspectorController> m_workerInspectorController; | 243 Persistent<WorkerInspectorController> m_workerInspectorController; |
243 | 244 |
244 // Signaled when the thread starts termination on the main thread. | 245 // Signaled when the thread starts termination on the main thread. |
245 std::unique_ptr<WaitableEvent> m_terminationEvent; | 246 std::unique_ptr<WaitableEvent> m_terminationEvent; |
246 | 247 |
247 // Signaled when the thread completes termination on the worker thread. | 248 // Signaled when the thread completes termination on the worker thread. |
248 std::unique_ptr<WaitableEvent> m_shutdownEvent; | 249 std::unique_ptr<WaitableEvent> m_shutdownEvent; |
249 | 250 |
250 // Scheduled when termination starts with TerminationMode::Force, and | 251 // Scheduled when termination starts with TerminationMode::Force, and |
251 // cancelled when the worker thread is gracefully shut down. | 252 // cancelled when the worker thread is gracefully shut down. |
252 std::unique_ptr<ForceTerminationTask> m_scheduledForceTerminationTask; | 253 std::unique_ptr<ForceTerminationTask> m_scheduledForceTerminationTask; |
253 | 254 |
254 Persistent<WorkerThreadLifecycleContext> m_workerThreadLifecycleContext; | 255 Persistent<WorkerThreadLifecycleContext> m_workerThreadLifecycleContext; |
255 }; | 256 }; |
256 | 257 |
257 } // namespace blink | 258 } // namespace blink |
258 | 259 |
259 #endif // WorkerThread_h | 260 #endif // WorkerThread_h |
OLD | NEW |