| 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 } | 187 } |
| 188 | 188 |
| 189 void WorkerThread::start(std::unique_ptr<WorkerThreadStartupData> startupData) | 189 void WorkerThread::start(std::unique_ptr<WorkerThreadStartupData> startupData) |
| 190 { | 190 { |
| 191 DCHECK(isMainThread()); | 191 DCHECK(isMainThread()); |
| 192 | 192 |
| 193 if (m_started) | 193 if (m_started) |
| 194 return; | 194 return; |
| 195 | 195 |
| 196 m_started = true; | 196 m_started = true; |
| 197 workerBackingThread().backingThread().postTask(BLINK_FROM_HERE, threadSafeBi
nd(&WorkerThread::initializeOnWorkerThread, AllowCrossThreadAccess(this), passed
(std::move(startupData)))); | 197 workerBackingThread().backingThread().postTask(BLINK_FROM_HERE, threadSafeBi
nd(&WorkerThread::initializeOnWorkerThread, crossThreadUnretained(this), passed(
std::move(startupData)))); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void WorkerThread::terminate() | 200 void WorkerThread::terminate() |
| 201 { | 201 { |
| 202 DCHECK(isMainThread()); | 202 DCHECK(isMainThread()); |
| 203 terminateInternal(TerminationMode::Graceful); | 203 terminateInternal(TerminationMode::Graceful); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void WorkerThread::terminateAndWait() | 206 void WorkerThread::terminateAndWait() |
| 207 { | 207 { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 MutexLocker lock(m_threadStateMutex); | 246 MutexLocker lock(m_threadStateMutex); |
| 247 if (m_terminated || m_readyToShutdown) | 247 if (m_terminated || m_readyToShutdown) |
| 248 return; | 248 return; |
| 249 } | 249 } |
| 250 | 250 |
| 251 bool isInstrumented = !task->taskNameForInstrumentation().isEmpty(); | 251 bool isInstrumented = !task->taskNameForInstrumentation().isEmpty(); |
| 252 if (isInstrumented) { | 252 if (isInstrumented) { |
| 253 DCHECK(isCurrentThread()); | 253 DCHECK(isCurrentThread()); |
| 254 InspectorInstrumentation::asyncTaskScheduled(workerGlobalScope(), "Worke
r task", task.get()); | 254 InspectorInstrumentation::asyncTaskScheduled(workerGlobalScope(), "Worke
r task", task.get()); |
| 255 } | 255 } |
| 256 workerBackingThread().backingThread().postTask(location, threadSafeBind(&Wor
kerThread::performTaskOnWorkerThread, AllowCrossThreadAccess(this), passed(std::
move(task)), isInstrumented)); | 256 workerBackingThread().backingThread().postTask(location, threadSafeBind(&Wor
kerThread::performTaskOnWorkerThread, crossThreadUnretained(this), passed(std::m
ove(task)), isInstrumented)); |
| 257 } | 257 } |
| 258 | 258 |
| 259 void WorkerThread::appendDebuggerTask(std::unique_ptr<CrossThreadClosure> task) | 259 void WorkerThread::appendDebuggerTask(std::unique_ptr<CrossThreadClosure> task) |
| 260 { | 260 { |
| 261 DCHECK(isMainThread()); | 261 DCHECK(isMainThread()); |
| 262 { | 262 { |
| 263 MutexLocker lock(m_threadStateMutex); | 263 MutexLocker lock(m_threadStateMutex); |
| 264 if (m_terminated) | 264 if (m_terminated) |
| 265 return; | 265 return; |
| 266 } | 266 } |
| 267 m_inspectorTaskRunner->appendTask(threadSafeBind(&WorkerThread::performDebug
gerTaskOnWorkerThread, AllowCrossThreadAccess(this), passed(std::move(task)))); | 267 m_inspectorTaskRunner->appendTask(threadSafeBind(&WorkerThread::performDebug
gerTaskOnWorkerThread, crossThreadUnretained(this), passed(std::move(task)))); |
| 268 { | 268 { |
| 269 MutexLocker lock(m_threadStateMutex); | 269 MutexLocker lock(m_threadStateMutex); |
| 270 if (isolate() && !m_readyToShutdown) | 270 if (isolate() && !m_readyToShutdown) |
| 271 m_inspectorTaskRunner->interruptAndRunAllTasksDontWait(isolate()); | 271 m_inspectorTaskRunner->interruptAndRunAllTasksDontWait(isolate()); |
| 272 } | 272 } |
| 273 workerBackingThread().backingThread().postTask(BLINK_FROM_HERE, threadSafeBi
nd(&WorkerThread::performDebuggerTaskDontWaitOnWorkerThread, AllowCrossThreadAcc
ess(this))); | 273 workerBackingThread().backingThread().postTask(BLINK_FROM_HERE, threadSafeBi
nd(&WorkerThread::performDebuggerTaskDontWaitOnWorkerThread, crossThreadUnretain
ed(this))); |
| 274 } | 274 } |
| 275 | 275 |
| 276 void WorkerThread::startRunningDebuggerTasksOnPauseOnWorkerThread() | 276 void WorkerThread::startRunningDebuggerTasksOnPauseOnWorkerThread() |
| 277 { | 277 { |
| 278 DCHECK(isCurrentThread()); | 278 DCHECK(isCurrentThread()); |
| 279 m_pausedInDebugger = true; | 279 m_pausedInDebugger = true; |
| 280 ThreadDebugger::idleStarted(isolate()); | 280 ThreadDebugger::idleStarted(isolate()); |
| 281 std::unique_ptr<CrossThreadClosure> task; | 281 std::unique_ptr<CrossThreadClosure> task; |
| 282 do { | 282 do { |
| 283 { | 283 { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 m_exitCode = ExitCode::SyncForciblyTerminated; | 412 m_exitCode = ExitCode::SyncForciblyTerminated; |
| 413 } else { | 413 } else { |
| 414 DCHECK_EQ(TerminationMode::Graceful, mode); | 414 DCHECK_EQ(TerminationMode::Graceful, mode); |
| 415 DCHECK(!m_scheduledForceTerminationTask); | 415 DCHECK(!m_scheduledForceTerminationTask); |
| 416 m_scheduledForceTerminationTask = ForceTerminationTask::create(this)
; | 416 m_scheduledForceTerminationTask = ForceTerminationTask::create(this)
; |
| 417 m_scheduledForceTerminationTask->schedule(); | 417 m_scheduledForceTerminationTask->schedule(); |
| 418 } | 418 } |
| 419 } | 419 } |
| 420 | 420 |
| 421 m_inspectorTaskRunner->kill(); | 421 m_inspectorTaskRunner->kill(); |
| 422 workerBackingThread().backingThread().postTask(BLINK_FROM_HERE, threadSafeBi
nd(&WorkerThread::prepareForShutdownOnWorkerThread, AllowCrossThreadAccess(this)
)); | 422 workerBackingThread().backingThread().postTask(BLINK_FROM_HERE, threadSafeBi
nd(&WorkerThread::prepareForShutdownOnWorkerThread, crossThreadUnretained(this))
); |
| 423 workerBackingThread().backingThread().postTask(BLINK_FROM_HERE, threadSafeBi
nd(&WorkerThread::performShutdownOnWorkerThread, AllowCrossThreadAccess(this))); | 423 workerBackingThread().backingThread().postTask(BLINK_FROM_HERE, threadSafeBi
nd(&WorkerThread::performShutdownOnWorkerThread, crossThreadUnretained(this))); |
| 424 } | 424 } |
| 425 | 425 |
| 426 void WorkerThread::forciblyTerminateExecution() | 426 void WorkerThread::forciblyTerminateExecution() |
| 427 { | 427 { |
| 428 DCHECK(m_workerGlobalScope); | 428 DCHECK(m_workerGlobalScope); |
| 429 m_workerGlobalScope->scriptController()->willScheduleExecutionTermination(); | 429 m_workerGlobalScope->scriptController()->willScheduleExecutionTermination(); |
| 430 isolate()->TerminateExecution(); | 430 isolate()->TerminateExecution(); |
| 431 } | 431 } |
| 432 | 432 |
| 433 void WorkerThread::initializeOnWorkerThread(std::unique_ptr<WorkerThreadStartupD
ata> startupData) | 433 void WorkerThread::initializeOnWorkerThread(std::unique_ptr<WorkerThreadStartupD
ata> startupData) |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 (*task)(); | 618 (*task)(); |
| 619 } | 619 } |
| 620 | 620 |
| 621 WorkerThread::ExitCode WorkerThread::getExitCode() | 621 WorkerThread::ExitCode WorkerThread::getExitCode() |
| 622 { | 622 { |
| 623 MutexLocker lock(m_threadStateMutex); | 623 MutexLocker lock(m_threadStateMutex); |
| 624 return m_exitCode; | 624 return m_exitCode; |
| 625 } | 625 } |
| 626 | 626 |
| 627 } // namespace blink | 627 } // namespace blink |
| OLD | NEW |