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

Side by Side Diff: src/ports/SkThread_pthread.cpp

Issue 19240007: Split TLS implementation into its own translation unit. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Explicitly set static initializers used before explicit assignment. Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/ports/SkThread_none.cpp ('k') | src/ports/SkThread_win.cpp » ('j') | 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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkThread.h" 8 #include "SkThread.h"
9 #include "SkTLS.h"
10 9
11 #include <pthread.h> 10 #include <pthread.h>
12 #include <errno.h> 11 #include <errno.h>
13 12
14 #ifndef SK_BUILD_FOR_ANDROID 13 #ifndef SK_BUILD_FOR_ANDROID
15 14
16 /** 15 /**
17 We prefer the GCC intrinsic implementation of the atomic operations over the 16 We prefer the GCC intrinsic implementation of the atomic operations over the
18 SkMutex-based implementation. The SkMutex version suffers from static 17 SkMutex-based implementation. The SkMutex version suffers from static
19 destructor ordering problems. 18 destructor ordering problems.
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 SkASSERT(0 == status); 188 SkASSERT(0 == status);
190 } 189 }
191 190
192 void SkMutex::release() { 191 void SkMutex::release() {
193 int status = pthread_mutex_unlock((pthread_mutex_t*)fStorage); 192 int status = pthread_mutex_unlock((pthread_mutex_t*)fStorage);
194 print_pthread_error(status); 193 print_pthread_error(status);
195 SkASSERT(0 == status); 194 SkASSERT(0 == status);
196 } 195 }
197 196
198 #endif // !SK_USE_POSIX_THREADS 197 #endif // !SK_USE_POSIX_THREADS
199
200 ///////////////////////////////////////////////////////////////////////////////
201
202 static pthread_key_t gSkTLSKey;
203 static pthread_once_t gSkTLSKey_Once = PTHREAD_ONCE_INIT;
204
205 static void sk_tls_make_key() {
206 (void)pthread_key_create(&gSkTLSKey, SkTLS::Destructor);
207 }
208
209 void* SkTLS::PlatformGetSpecific(bool forceCreateTheSlot) {
210 // should we use forceCreateTheSlot to potentially skip calling pthread_once
211 // and just return NULL if we've never been called with
212 // forceCreateTheSlot==true ?
213
214 (void)pthread_once(&gSkTLSKey_Once, sk_tls_make_key);
215 return pthread_getspecific(gSkTLSKey);
216 }
217
218 void SkTLS::PlatformSetSpecific(void* ptr) {
219 (void)pthread_setspecific(gSkTLSKey, ptr);
220 }
OLDNEW
« no previous file with comments | « src/ports/SkThread_none.cpp ('k') | src/ports/SkThread_win.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698