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

Side by Side Diff: Source/platform/heap/Handle.h

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) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 162
163 private: 163 private:
164 static ThreadState* state() { return ThreadStateFor<Affinity>::state(); } 164 static ThreadState* state() { return ThreadStateFor<Affinity>::state(); }
165 }; 165 };
166 166
167 // RootsAccessor for Persistent that provides synchronized access to global 167 // RootsAccessor for Persistent that provides synchronized access to global
168 // list of persistent handles. Can be used for persistent handles that are 168 // list of persistent handles. Can be used for persistent handles that are
169 // passed between threads. 169 // passed between threads.
170 class GlobalPersistents { 170 class GlobalPersistents {
171 public: 171 public:
172 static PersistentNode* roots() { return ThreadState::globalRoots(); } 172 static PersistentNode* roots() { return &ThreadState::globalRoots(); }
173 173
174 class Lock { 174 class Lock {
175 public: 175 public:
176 Lock() : m_locker(ThreadState::globalRootsMutex()) { } 176 Lock() : m_locker(ThreadState::globalRootsMutex()) { }
177 private: 177 private:
178 MutexLocker m_locker; 178 MutexLocker m_locker;
179 }; 179 };
180 }; 180 };
181 181
182 // Base class for persistent handles. RootsAccessor specifies which list to 182 // Base class for persistent handles. RootsAccessor specifies which list to
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 template<typename T> 1184 template<typename T>
1185 struct ParamStorageTraits<RawPtr<T>> : public PointerParamStorageTraits<T*, blin k::IsGarbageCollectedType<T>::value> { 1185 struct ParamStorageTraits<RawPtr<T>> : public PointerParamStorageTraits<T*, blin k::IsGarbageCollectedType<T>::value> {
1186 }; 1186 };
1187 1187
1188 template<typename T> 1188 template<typename T>
1189 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; 1189 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete;
1190 1190
1191 } // namespace WTF 1191 } // namespace WTF
1192 1192
1193 #endif 1193 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698