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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 workerGlobalScope->removeAllEventListeners(); | 396 workerGlobalScope->removeAllEventListeners(); |
397 | 397 |
398 // Stick a shutdown command at the end of the queue, so that we deal | 398 // Stick a shutdown command at the end of the queue, so that we deal |
399 // with all the cleanup tasks the databases post first. | 399 // with all the cleanup tasks the databases post first. |
400 workerGlobalScope->postTask(WorkerThreadShutdownFinishTask::create()); | 400 workerGlobalScope->postTask(WorkerThreadShutdownFinishTask::create()); |
401 } | 401 } |
402 | 402 |
403 virtual bool isCleanupTask() const { return true; } | 403 virtual bool isCleanupTask() const { return true; } |
404 }; | 404 }; |
405 | 405 |
406 void WorkerThread::stop() | 406 void WorkerThread::stop() |
haraken
2014/10/30 05:12:13
Nit: We might want to rename "stop" to "terminate"
| |
407 { | 407 { |
408 // Prevent the deadlock between GC and an attempt to stop a thread. | 408 // Prevent the deadlock between GC and an attempt to stop a thread. |
409 ThreadState::SafePointScope safePointScope(ThreadState::HeapPointersOnStack) ; | 409 ThreadState::SafePointScope safePointScope(ThreadState::HeapPointersOnStack) ; |
410 stopInternal(); | 410 stopInternal(); |
411 } | 411 } |
412 | 412 |
413 void WorkerThread::stopInShutdownSequence() | 413 void WorkerThread::stopInShutdownSequence() |
414 { | 414 { |
415 stopInternal(); | 415 stopInternal(); |
416 } | 416 } |
417 | 417 |
418 void WorkerThread::terminateAndWait() | |
419 { | |
420 stop(); | |
horo
2014/10/30 08:14:47
I think we don't need to call stop() from the dest
Kunihiko Sakamoto
2014/10/30 08:31:29
Done.
| |
421 terminationEvent()->wait(); | |
422 } | |
423 | |
418 bool WorkerThread::terminated() | 424 bool WorkerThread::terminated() |
419 { | 425 { |
420 MutexLocker lock(m_threadCreationMutex); | 426 MutexLocker lock(m_threadCreationMutex); |
421 return m_terminated; | 427 return m_terminated; |
422 } | 428 } |
423 | 429 |
424 void WorkerThread::stopInternal() | 430 void WorkerThread::stopInternal() |
425 { | 431 { |
426 // Protect against this method and initialize() racing each other. | 432 // Protect against this method and initialize() racing each other. |
427 MutexLocker lock(m_threadCreationMutex); | 433 MutexLocker lock(m_threadCreationMutex); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 InspectorInstrumentation::didLeaveNestedRunLoop(m_workerGlobalScope.get()); | 532 InspectorInstrumentation::didLeaveNestedRunLoop(m_workerGlobalScope.get()); |
527 } | 533 } |
528 | 534 |
529 void WorkerThread::setWorkerInspectorController(WorkerInspectorController* worke rInspectorController) | 535 void WorkerThread::setWorkerInspectorController(WorkerInspectorController* worke rInspectorController) |
530 { | 536 { |
531 MutexLocker locker(m_workerInspectorControllerMutex); | 537 MutexLocker locker(m_workerInspectorControllerMutex); |
532 m_workerInspectorController = workerInspectorController; | 538 m_workerInspectorController = workerInspectorController; |
533 } | 539 } |
534 | 540 |
535 } // namespace blink | 541 } // namespace blink |
OLD | NEW |