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

Side by Side Diff: Source/wtf/unicode/icu/CollatorICU.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
« Source/wtf/Threading.h ('K') | « Source/wtf/text/TextEncoding.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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 29 matching lines...) Expand all
40 #if OS(MACOSX) 40 #if OS(MACOSX)
41 #include "wtf/RetainPtr.h" 41 #include "wtf/RetainPtr.h"
42 #include <CoreFoundation/CoreFoundation.h> 42 #include <CoreFoundation/CoreFoundation.h>
43 #endif 43 #endif
44 44
45 namespace WTF { 45 namespace WTF {
46 46
47 static UCollator* cachedCollator; 47 static UCollator* cachedCollator;
48 static Mutex& cachedCollatorMutex() 48 static Mutex& cachedCollatorMutex()
49 { 49 {
50 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); 50 AtomicallyInitializedStaticReference(Mutex, mutex, new Mutex);
51 return mutex; 51 return mutex;
52 } 52 }
53 53
54 Collator::Collator(const char* locale) 54 Collator::Collator(const char* locale)
55 : m_collator(0) 55 : m_collator(0)
56 , m_locale(locale ? strdup(locale) : 0) 56 , m_locale(locale ? strdup(locale) : 0)
57 , m_lowerFirst(false) 57 , m_lowerFirst(false)
58 { 58 {
59 } 59 }
60 60
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 { 137 {
138 Locker<Mutex> lock(cachedCollatorMutex()); 138 Locker<Mutex> lock(cachedCollatorMutex());
139 if (cachedCollator) 139 if (cachedCollator)
140 ucol_close(cachedCollator); 140 ucol_close(cachedCollator);
141 cachedCollator = m_collator; 141 cachedCollator = m_collator;
142 m_collator = 0; 142 m_collator = 0;
143 } 143 }
144 } 144 }
145 145
146 } // namespace WTF 146 } // namespace WTF
OLDNEW
« Source/wtf/Threading.h ('K') | « Source/wtf/text/TextEncoding.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698