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

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

Issue 644663004: Use C++11 features in core/workers. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « Source/core/workers/WorkerScriptLoader.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 Closure m_closure; 110 Closure m_closure;
111 bool m_taskCanceled; 111 bool m_taskCanceled;
112 }; 112 };
113 113
114 class WorkerSharedTimer : public SharedTimer { 114 class WorkerSharedTimer : public SharedTimer {
115 public: 115 public:
116 explicit WorkerSharedTimer(WorkerThread* workerThread) 116 explicit WorkerSharedTimer(WorkerThread* workerThread)
117 : m_workerThread(workerThread) 117 : m_workerThread(workerThread)
118 , m_nextFireTime(0.0) 118 , m_nextFireTime(0.0)
119 , m_running(false) 119 , m_running(false)
120 , m_lastQueuedTask(0) 120 , m_lastQueuedTask(nullptr)
121 { } 121 { }
122 122
123 typedef void (*SharedTimerFunction)(); 123 typedef void (*SharedTimerFunction)();
124 virtual void setFiredFunction(SharedTimerFunction func) 124 virtual void setFiredFunction(SharedTimerFunction func)
125 { 125 {
126 m_sharedTimerFunction = func; 126 m_sharedTimerFunction = func;
127 if (!m_sharedTimerFunction) 127 if (!m_sharedTimerFunction)
128 m_nextFireTime = 0.0; 128 m_nextFireTime = 0.0;
129 } 129 }
130 130
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 InspectorInstrumentation::didKillAllExecutionContextTasks(m_workerGlobalScop e.get()); 440 InspectorInstrumentation::didKillAllExecutionContextTasks(m_workerGlobalScop e.get());
441 m_debuggerMessageQueue.kill(); 441 m_debuggerMessageQueue.kill();
442 postTask(WorkerThreadShutdownStartTask::create()); 442 postTask(WorkerThreadShutdownStartTask::create());
443 } 443 }
444 444
445 void WorkerThread::terminateAndWaitForAllWorkers() 445 void WorkerThread::terminateAndWaitForAllWorkers()
446 { 446 {
447 // Keep this lock to prevent WorkerThread instances from being destroyed. 447 // Keep this lock to prevent WorkerThread instances from being destroyed.
448 MutexLocker lock(threadSetMutex()); 448 MutexLocker lock(threadSetMutex());
449 HashSet<WorkerThread*> threads = workerThreads(); 449 HashSet<WorkerThread*> threads = workerThreads();
450 for (HashSet<WorkerThread*>::iterator itr = threads.begin(); itr != threads. end(); ++itr) 450 for (WorkerThread* thread : threads)
451 (*itr)->stopInShutdownSequence(); 451 thread->stopInShutdownSequence();
452 452
453 for (HashSet<WorkerThread*>::iterator itr = threads.begin(); itr != threads. end(); ++itr) 453 for (WorkerThread* thread : threads)
454 (*itr)->terminationEvent()->wait(); 454 thread->terminationEvent()->wait();
455 } 455 }
456 456
457 bool WorkerThread::isCurrentThread() const 457 bool WorkerThread::isCurrentThread() const
458 { 458 {
459 return m_thread && m_thread->isCurrentThread(); 459 return m_thread && m_thread->isCurrentThread();
460 } 460 }
461 461
462 void WorkerThread::idleHandler() 462 void WorkerThread::idleHandler()
463 { 463 {
464 ASSERT(m_workerGlobalScope.get()); 464 ASSERT(m_workerGlobalScope.get());
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 InspectorInstrumentation::didLeaveNestedRunLoop(m_workerGlobalScope.get()); 523 InspectorInstrumentation::didLeaveNestedRunLoop(m_workerGlobalScope.get());
524 } 524 }
525 525
526 void WorkerThread::setWorkerInspectorController(WorkerInspectorController* worke rInspectorController) 526 void WorkerThread::setWorkerInspectorController(WorkerInspectorController* worke rInspectorController)
527 { 527 {
528 MutexLocker locker(m_workerInspectorControllerMutex); 528 MutexLocker locker(m_workerInspectorControllerMutex);
529 m_workerInspectorController = workerInspectorController; 529 m_workerInspectorController = workerInspectorController;
530 } 530 }
531 531
532 } // namespace blink 532 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerScriptLoader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698