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

Side by Side Diff: third_party/WebKit/Source/wtf/ThreadSpecific.h

Issue 2585673002: Replace ASSERT, ENABLE(ASSERT), and ASSERT_NOT_REACHED in wtf (Closed)
Patch Set: Fix an Asan issue with LinkedHashSetNodeBase::unlink Created 4 years 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 * Copyright (C) 2009 Jian Li <jianli@chromium.org> 3 * Copyright (C) 2009 Jian Li <jianli@chromium.org>
4 * Copyright (C) 2012 Patrick Gansterer <paroga@paroga.com> 4 * Copyright (C) 2012 Patrick Gansterer <paroga@paroga.com>
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 148 }
149 149
150 template <typename T> 150 template <typename T>
151 inline T* ThreadSpecific<T>::get() { 151 inline T* ThreadSpecific<T>::get() {
152 Data* data = static_cast<Data*>(pthread_getspecific(m_key)); 152 Data* data = static_cast<Data*>(pthread_getspecific(m_key));
153 return data ? data->value : 0; 153 return data ? data->value : 0;
154 } 154 }
155 155
156 template <typename T> 156 template <typename T>
157 inline void ThreadSpecific<T>::set(T* ptr) { 157 inline void ThreadSpecific<T>::set(T* ptr) {
158 ASSERT(!get()); 158 DCHECK(!get());
159 pthread_setspecific(m_key, new Data(ptr, this)); 159 pthread_setspecific(m_key, new Data(ptr, this));
160 } 160 }
161 161
162 #elif OS(WIN) 162 #elif OS(WIN)
163 163
164 // TLS_OUT_OF_INDEXES is not defined on WinCE. 164 // TLS_OUT_OF_INDEXES is not defined on WinCE.
165 #ifndef TLS_OUT_OF_INDEXES 165 #ifndef TLS_OUT_OF_INDEXES
166 #define TLS_OUT_OF_INDEXES 0xffffffff 166 #define TLS_OUT_OF_INDEXES 0xffffffff
167 #endif 167 #endif
168 168
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 205 }
206 206
207 template <typename T> 207 template <typename T>
208 inline T* ThreadSpecific<T>::get() { 208 inline T* ThreadSpecific<T>::get() {
209 Data* data = static_cast<Data*>(TlsGetValue(tlsKeys()[m_index])); 209 Data* data = static_cast<Data*>(TlsGetValue(tlsKeys()[m_index]));
210 return data ? data->value : 0; 210 return data ? data->value : 0;
211 } 211 }
212 212
213 template <typename T> 213 template <typename T>
214 inline void ThreadSpecific<T>::set(T* ptr) { 214 inline void ThreadSpecific<T>::set(T* ptr) {
215 ASSERT(!get()); 215 DCHECK(!get());
216 Data* data = new Data(ptr, this); 216 Data* data = new Data(ptr, this);
217 data->destructor = &ThreadSpecific<T>::destroy; 217 data->destructor = &ThreadSpecific<T>::destroy;
218 TlsSetValue(tlsKeys()[m_index], data); 218 TlsSetValue(tlsKeys()[m_index], data);
219 } 219 }
220 220
221 #else 221 #else
222 #error ThreadSpecific is not implemented for this platform. 222 #error ThreadSpecific is not implemented for this platform.
223 #endif 223 #endif
224 224
225 template <typename T> 225 template <typename T>
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 template <typename T> 278 template <typename T>
279 inline T& ThreadSpecific<T>::operator*() { 279 inline T& ThreadSpecific<T>::operator*() {
280 return *operator T*(); 280 return *operator T*();
281 } 281 }
282 282
283 } // namespace WTF 283 } // namespace WTF
284 284
285 using WTF::ThreadSpecific; 285 using WTF::ThreadSpecific;
286 286
287 #endif // WTF_ThreadSpecific_h 287 #endif // WTF_ThreadSpecific_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/ThreadRestrictionVerifier.h ('k') | third_party/WebKit/Source/wtf/ThreadingPrimitives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698