Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1292)

Side by Side Diff: Source/core/workers/WorkerThread.cpp

Issue 1168843003: Minor cleanup for WorkerThread::stop (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 } 286 }
287 287
288 288
289 void WorkerThread::stop() 289 void WorkerThread::stop()
290 { 290 {
291 // Prevent the deadlock between GC and an attempt to stop a thread. 291 // Prevent the deadlock between GC and an attempt to stop a thread.
292 SafePointScope safePointScope(ThreadState::HeapPointersOnStack); 292 SafePointScope safePointScope(ThreadState::HeapPointersOnStack);
293 stopInternal(); 293 stopInternal();
294 } 294 }
295 295
296 void WorkerThread::stopInShutdownSequence()
297 {
298 stopInternal();
299 }
300
301 void WorkerThread::terminateAndWait() 296 void WorkerThread::terminateAndWait()
302 { 297 {
303 stop(); 298 stop();
304 m_terminationEvent->wait(); 299 m_terminationEvent->wait();
305 } 300 }
306 301
307 bool WorkerThread::terminated() 302 bool WorkerThread::terminated()
308 { 303 {
309 MutexLocker lock(m_threadStateMutex); 304 MutexLocker lock(m_threadStateMutex);
310 return m_terminated; 305 return m_terminated;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 ASSERT(isCurrentThread()); 348 ASSERT(isCurrentThread());
354 Platform::current()->didStopWorkerRunLoop(); 349 Platform::current()->didStopWorkerRunLoop();
355 } 350 }
356 351
357 void WorkerThread::terminateAndWaitForAllWorkers() 352 void WorkerThread::terminateAndWaitForAllWorkers()
358 { 353 {
359 // Keep this lock to prevent WorkerThread instances from being destroyed. 354 // Keep this lock to prevent WorkerThread instances from being destroyed.
360 MutexLocker lock(threadSetMutex()); 355 MutexLocker lock(threadSetMutex());
361 HashSet<WorkerThread*> threads = workerThreads(); 356 HashSet<WorkerThread*> threads = workerThreads();
362 for (WorkerThread* thread : threads) 357 for (WorkerThread* thread : threads)
363 thread->stopInShutdownSequence(); 358 thread->stopInternal();
364 359
365 for (WorkerThread* thread : threads) 360 for (WorkerThread* thread : threads)
366 thread->terminationEvent()->wait(); 361 thread->terminationEvent()->wait();
367 } 362 }
368 363
369 bool WorkerThread::isCurrentThread() 364 bool WorkerThread::isCurrentThread()
370 { 365 {
371 return m_started && backingThread().isCurrentThread(); 366 return m_started && backingThread().isCurrentThread();
372 } 367 }
373 368
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 InspectorInstrumentation::didLeaveNestedRunLoop(m_workerGlobalScope.get()); 472 InspectorInstrumentation::didLeaveNestedRunLoop(m_workerGlobalScope.get());
478 } 473 }
479 474
480 void WorkerThread::setWorkerInspectorController(WorkerInspectorController* worke rInspectorController) 475 void WorkerThread::setWorkerInspectorController(WorkerInspectorController* worke rInspectorController)
481 { 476 {
482 MutexLocker locker(m_workerInspectorControllerMutex); 477 MutexLocker locker(m_workerInspectorControllerMutex);
483 m_workerInspectorController = workerInspectorController; 478 m_workerInspectorController = workerInspectorController;
484 } 479 }
485 480
486 } // namespace blink 481 } // namespace blink
OLDNEW
« Source/core/workers/WorkerThread.h ('K') | « Source/core/workers/WorkerThread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698