Line data Source code
1 : /*
2 : * Copyright 2013 Google Inc.
3 : *
4 : * Use of this source code is governed by a BSD-style license that can be
5 : * found in the LICENSE file.
6 : */
7 :
8 : #include "SkTLS.h"
9 : #include "SkOnce.h"
10 :
11 : #include <pthread.h>
12 :
13 : static pthread_key_t gSkTLSKey;
14 :
15 0 : void* SkTLS::PlatformGetSpecific(bool forceCreateTheSlot) {
16 : // should we use forceCreateTheSlot to potentially just return nullptr if
17 : // we've never been called with forceCreateTheSlot==true ?
18 : static SkOnce once;
19 0 : once(pthread_key_create, &gSkTLSKey, SkTLS::Destructor);
20 0 : return pthread_getspecific(gSkTLSKey);
21 : }
22 :
23 0 : void SkTLS::PlatformSetSpecific(void* ptr) {
24 0 : (void)pthread_setspecific(gSkTLSKey, ptr);
25 0 : }
|