[asterisk-commits] russell: branch group/asterisk-cpp r168373 - /team/group/asterisk-cpp/include...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jan 9 21:40:26 CST 2009
Author: russell
Date: Fri Jan 9 21:40:26 2009
New Revision: 168373
URL: http://svn.digium.com/view/asterisk?view=rev&rev=168373
Log:
Make threadstorage.h C++ friendly
Modified:
team/group/asterisk-cpp/include/asterisk/threadstorage.h
Modified: team/group/asterisk-cpp/include/asterisk/threadstorage.h
URL: http://svn.digium.com/view/asterisk/team/group/asterisk-cpp/include/asterisk/threadstorage.h?view=diff&rev=168373&r1=168372&r2=168373
==============================================================================
--- team/group/asterisk-cpp/include/asterisk/threadstorage.h (original)
+++ team/group/asterisk-cpp/include/asterisk/threadstorage.h Fri Jan 9 21:40:26 2009
@@ -54,10 +54,17 @@
* \brief data for a thread locally stored variable
*/
struct ast_threadstorage {
+ typedef void (*key_init_fn)(void);
+ typedef int (*custom_init_fn)(void *);
+
+ ast_threadstorage(key_init_fn key_fn, custom_init_fn custom_fn) :
+ once(PTHREAD_ONCE_INIT), key_init(key_fn), custom_init(custom_fn)
+ {}
+
pthread_once_t once; /*!< Ensure that the key is only initialized by one thread */
pthread_key_t key; /*!< The key used to retrieve this thread's data */
- void (*key_init)(void); /*!< The function that initializes the key */
- int (*custom_init)(void *); /*!< Custom initialization function specific to the object */
+ key_init_fn key_init; /*!< The function that initializes the key */
+ custom_init_fn custom_init; /*!< Custom initialization function specific to the object */
};
#ifdef SOLARIS
@@ -112,11 +119,7 @@
#if !defined(DEBUG_THREADLOCALS)
#define AST_THREADSTORAGE_CUSTOM_SCOPE(name, c_init, c_cleanup, scope) \
static void __init_##name(void); \
-scope struct ast_threadstorage name = { \
- .once = THREADSTORAGE_ONCE_INIT, \
- .key_init = __init_##name, \
- .custom_init = c_init, \
-}; \
+scope struct ast_threadstorage name = ast_threadstorage(__init_##name, c_init); \
static void __init_##name(void) \
{ \
pthread_key_create(&(name).key, c_cleanup); \
@@ -124,11 +127,7 @@
#else /* defined(DEBUG_THREADLOCALS) */
#define AST_THREADSTORAGE_CUSTOM_SCOPE(name, c_init, c_cleanup, scope) \
static void __init_##name(void); \
-scope struct ast_threadstorage name = { \
- .once = THREADSTORAGE_ONCE_INIT, \
- .key_init = __init_##name, \
- .custom_init = c_init, \
-}; \
+scope struct ast_threadstorage name = ast_threadstorage(__init_##name, c_init); \
static void __cleanup_##name(void *data) \
{ \
__ast_threadstorage_object_remove(data); \
More information about the asterisk-commits
mailing list