Chromium Code Reviews| Index: src/IceTLS.h |
| diff --git a/src/IceTLS.h b/src/IceTLS.h |
| index 9a20e70d931943de240ae507ad071d5a4ccd8621..11b6e4b2d152ffe68ab8c5e6ab709ae97cb27211 100644 |
| --- a/src/IceTLS.h |
| +++ b/src/IceTLS.h |
| @@ -17,37 +17,45 @@ |
| #ifndef SUBZERO_SRC_ICETLS_H |
| #define SUBZERO_SRC_ICETLS_H |
| -#if defined(_MSC_VER) |
| -#define ICE_ATTRIBUTE_TLS __declspec(thread) |
| -#else // !_MSC_VER |
| -#define ICE_ATTRIBUTE_TLS thread_local |
| -#endif // !_MSC_VER |
| -// Defines 4 macros for unifying thread_local and pthread: |
| -// |
| -// ICE_TLS_DECLARE_FIELD(Type, FieldName): Declare a static thread_local field |
| -// inside the current class definition. "Type" needs to be a pointer type, such |
| -// as int* or class Foo*. |
| -// |
| -// ICE_TLS_DEFINE_FIELD(Type, ClassName, FieldName): Define a static |
| -// thread_local field outside of its class definition. The field will |
| -// ultimately be initialized to nullptr. |
| -// |
| -// ICE_TLS_INIT_FIELD(FieldName): Ensure the thread_local field is properly |
| -// initialized. This is intended to be called from within a static method of |
| -// the field's class after main() starts (to ensure that the pthread library is |
| -// fully initialized) but before any uses of ICE_TLS_GET_FIELD or |
| -// ICE_TLS_SET_FIELD. |
| -// |
| -// ICE_TLS_GET_FIELD(Type, FieldName): Read the value of the static |
| -// thread_local field. Must be done within the context of its class. |
| -// |
| -// ICE_TLS_SET_FIELD(FieldName, Value): Write a value into the static |
| -// thread_local field. Must be done within the context of its class. |
| +/// |
| +/// @defgroup /IceTLC Defines 5 macros for unifying thread_local and pthread: |
|
Jim Stichnoth
2015/11/09 22:49:52
IceTLC? Should this be IceTLS?
rkotlerimgtec
2015/11/09 23:59:50
Done.
|
| +/// @{ |
| +/// |
| +/// \def ICE_TLS_DECLARE_FIELD(Type, FieldName) |
| +/// Declare a static thread_local field |
|
Jim Stichnoth
2015/11/09 22:49:52
Reflow the remainders of all these comments to 80-
rkotlerimgtec
2015/11/09 23:59:50
Done.
|
| +/// inside the current class definition. "Type" needs to be a pointer type, such |
| +/// as int* or class Foo*. |
| +/// |
| +/// \def ICE_TLS_DEFINE_FIELD(Type, ClassName, FieldName) |
| +/// Define a static |
| +/// thread_local field outside of its class definition. The field will |
| +/// ultimately be initialized to nullptr. |
| +/// |
| +/// \def ICE_TLS_INIT_FIELD(FieldName) |
| +/// Ensure the thread_local field is properly initialized. |
| +/// This is intended to be called from within a static method of |
| +/// the field's class after main() starts (to ensure that the pthread library is |
| +/// fully initialized) but before any uses of ICE_TLS_GET_FIELD or |
| +/// ICE_TLS_SET_FIELD. |
| +/// |
| +/// \def ICE_TLS_GET_FIELD(Type, FieldName) |
| +/// Read the value of the static |
| +/// thread_local field. Must be done within the context of its class. |
| +/// |
| +/// \def ICE_TLS_SET_FIELD(FieldName, Value) |
| +/// Write a value into the static |
| +/// thread_local field. Must be done within the context of its class. |
| + |
| +/// \todo TODO(stichnot) |
| +///Limit this define to only the platforms that |
| +/// absolutely require it. And ideally, eventually remove this hack |
| +/// altogether. |
| +/// |
| -// TODO(stichnot): Limit this define to only the platforms that |
| -// absolutely require it. And ideally, eventually remove this hack |
| -// altogether. |
| +/// |
| +/// \def ICE_THREAD_LOCAL_HACK |
| +/// |
| #define ICE_THREAD_LOCAL_HACK |
| #ifdef ICE_THREAD_LOCAL_HACK |
| @@ -86,6 +94,13 @@ |
| #else // !ICE_THREAD_LOCAL_HACK |
| +#if defined(_MSC_VER) |
| +#define ICE_ATTRIBUTE_TLS __declspec(thread) |
| +#else // !_MSC_VER |
| +#define ICE_ATTRIBUTE_TLS thread_local |
| +#endif // !_MSC_VER |
| + |
| + |
| #define ICE_TLS_DECLARE_FIELD(Type, FieldName) \ |
| static ICE_ATTRIBUTE_TLS Type FieldName |
| #define ICE_TLS_DEFINE_FIELD(Type, ClassName, FieldName) \ |
| @@ -96,4 +111,8 @@ |
| #endif // !ICE_THREAD_LOCAL_HACK |
| +/// |
| +/// @} |
| +/// |
| + |
| #endif // SUBZERO_SRC_ICETLS_H |