[Bf-blender-cvs] [ba7eb0c] master: Add utility macro to work with thread local storage
Sergey Sharybin
noreply at git.blender.org
Thu Mar 3 12:02:48 CET 2016
Commit: ba7eb0c7b9d93987173780d5b819c7f2ec79b96e
Author: Sergey Sharybin
Date: Thu Mar 3 15:53:42 2016 +0500
Branches: master
https://developer.blender.org/rBba7eb0c7b9d93987173780d5b819c7f2ec79b96e
Add utility macro to work with thread local storage
===================================================================
M source/blender/blenlib/BLI_threads.h
===================================================================
diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h
index 6ae833d..b4a465b 100644
--- a/source/blender/blenlib/BLI_threads.h
+++ b/source/blender/blenlib/BLI_threads.h
@@ -181,6 +181,27 @@ bool BLI_thread_queue_is_empty(ThreadQueue *queue);
void BLI_thread_queue_wait_finish(ThreadQueue *queue);
void BLI_thread_queue_nowait(ThreadQueue *queue);
+
+/* Thread local storage */
+
+#if defined(__APPLE__)
+# define ThreadLocal(type) pthread_key_t
+# define BLI_thread_local_create(name) pthread_key_create(&name, NULL)
+# define BLI_thread_local_delete(name) pthread_key_delete(name)
+# define BLI_thread_local_get(name) pthread_getspecific(name)
+# define BLI_thread_local_set(name, value) pthread_setspecific(name, value)
+#else /* defined(__APPLE__) */
+# ifdef _MSC_VER
+# define ThreadLocal(type) __declspec(thread) type
+# else
+# define ThreadLocal(type) __thread type
+# endif
+# define BLI_thread_local_create(name)
+# define BLI_thread_local_delete(name)
+# define BLI_thread_local_get(name) name
+# define BLI_thread_local_set(name, value) name = value
+#endif /* defined(__APPLE__) */
+
#ifdef __cplusplus
}
#endif
More information about the Bf-blender-cvs
mailing list