1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Functions for allocating and accessing thread local values via key.
7 #ifndef GPU_COMMAND_BUFFER_COMMON_THREAD_LOCAL_H_
8 #define GPU_COMMAND_BUFFER_COMMON_THREAD_LOCAL_H_
19 typedef DWORD ThreadLocalKey
;
21 typedef pthread_key_t ThreadLocalKey
;
24 inline ThreadLocalKey
ThreadLocalAlloc() {
29 pthread_key_create(&key
, NULL
);
34 inline void ThreadLocalFree(ThreadLocalKey key
) {
38 pthread_key_delete(key
);
42 inline void ThreadLocalSetValue(ThreadLocalKey key
, void* value
) {
44 TlsSetValue(key
, value
);
46 pthread_setspecific(key
, value
);
50 inline void* ThreadLocalGetValue(ThreadLocalKey key
) {
52 return TlsGetValue(key
);
54 return pthread_getspecific(key
);
59 #endif // GPU_COMMAND_BUFFER_COMMON_THREAD_LOCAL_H_