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

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

Issue 794223003: Cheaper thread-safe atomic initialization of static references. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add type check for initial value Created 5 years, 11 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
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 { 64 {
65 Microtask::performCheckpoint(); 65 Microtask::performCheckpoint();
66 V8Initializer::reportRejectedPromises(); 66 V8Initializer::reportRejectedPromises();
67 } 67 }
68 }; 68 };
69 69
70 } // namespace 70 } // namespace
71 71
72 static Mutex& threadSetMutex() 72 static Mutex& threadSetMutex()
73 { 73 {
74 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); 74 AtomicallyInitializedStaticReference(Mutex, mutex, new Mutex);
75 return mutex; 75 return mutex;
76 } 76 }
77 77
78 static HashSet<WorkerThread*>& workerThreads() 78 static HashSet<WorkerThread*>& workerThreads()
79 { 79 {
80 DEFINE_STATIC_LOCAL(HashSet<WorkerThread*>, threads, ()); 80 DEFINE_STATIC_LOCAL(HashSet<WorkerThread*>, threads, ());
81 return threads; 81 return threads;
82 } 82 }
83 83
84 unsigned WorkerThread::workerThreadCount() 84 unsigned WorkerThread::workerThreadCount()
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 InspectorInstrumentation::didLeaveNestedRunLoop(m_workerGlobalScope.get()); 532 InspectorInstrumentation::didLeaveNestedRunLoop(m_workerGlobalScope.get());
533 } 533 }
534 534
535 void WorkerThread::setWorkerInspectorController(WorkerInspectorController* worke rInspectorController) 535 void WorkerThread::setWorkerInspectorController(WorkerInspectorController* worke rInspectorController)
536 { 536 {
537 MutexLocker locker(m_workerInspectorControllerMutex); 537 MutexLocker locker(m_workerInspectorControllerMutex);
538 m_workerInspectorController = workerInspectorController; 538 m_workerInspectorController = workerInspectorController;
539 } 539 }
540 540
541 } // namespace blink 541 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698