|
Go to the documentation of this file. 10 #define ADOBE_ONCE_HPP 14 #if defined(BOOST_HAS_THREADS) 15 #include <boost/thread.hpp> 26 #if defined(BOOST_HAS_THREADS) 31 #define ADOBE_ONCE_INIT BOOST_ONCE_INIT 45 #define ADOBE_ONCE_INIT false 66 #define ADOBE_ONCE_DECLARATION(signature) \ 67 struct adobe_initialize_constants_##signature##_t \ 69 adobe_initialize_constants_##signature##_t(); \ 72 #define ADOBE_ONCE_DEFINITION(signature, func) \ 74 adobe::once_flag adobe_once_flag_##signature##_s = ADOBE_ONCE_INIT; \ 76 adobe_initialize_constants_##signature##_t::adobe_initialize_constants_##signature##_t() \ 78 adobe::call_once(&func, adobe_once_flag_##signature##_s); \ 81 #define ADOBE_ONCE_INSTANCE(signature) \ 82 adobe_initialize_constants_##signature##_t adobe_initialize_constants_##signature##_s 84 #define ADOBE_ONCE_STATIC_INSTANCE(signature) \ 85 namespace { ADOBE_ONCE_INSTANCE(signature); } 87 #if defined(BOOST_HAS_THREADS) 89 #define ADOBE_GLOBAL_MUTEX_DEFINITION(signature) \ 91 adobe::once_flag adobe_once_flag_##signature##_s = ADOBE_ONCE_INIT; \ 92 boost::mutex* adobe_mutex_ptr_##signature##_s = 0; \ 93 void adobe_init_once_##signature() \ 95 static boost::mutex mutex_s; \ 96 adobe_mutex_ptr_##signature##_s = &mutex_s; \ 100 #define ADOBE_GLOBAL_MUTEX_INSTANCE(signature) \ 101 boost::call_once(&adobe_init_once_##signature, adobe_once_flag_##signature##_s); \ 102 boost::mutex::scoped_lock lock(*adobe_mutex_ptr_##signature##_s) 106 #define ADOBE_GLOBAL_MUTEX_DEFINITION(signature) 107 #define ADOBE_GLOBAL_MUTEX_INSTANCE(signature) 113 #if defined(BOOST_HAS_THREADS) 115 #define ADOBE_THREAD_LOCAL_STORAGE_1(type, signature, ctor_p1) \ 117 typedef boost::thread_specific_ptr< type > adobe_thread_local_storage_##signature##_t; \ 118 adobe_thread_local_storage_##signature##_t* adobe_thread_local_storage_##signature##_g = 0;\ 119 type& adobe_thread_local_storage_##signature##_access(); \ 120 type& adobe_thread_local_storage_##signature##_access() \ 122 type* result = adobe_thread_local_storage_##signature##_g->get(); \ 123 if (result) return *result; \ 124 result = new type(ctor_p1); \ 125 adobe_thread_local_storage_##signature##_g->reset(result); \ 129 #define ADOBE_THREAD_LOCAL_STORAGE(type, signature) \ 131 typedef boost::thread_specific_ptr< type > adobe_thread_local_storage_##signature##_t; \ 132 adobe_thread_local_storage_##signature##_t* adobe_thread_local_storage_##signature##_g = 0;\ 133 type& adobe_thread_local_storage_##signature##_access(); \ 134 type& adobe_thread_local_storage_##signature##_access() \ 136 type* result = adobe_thread_local_storage_##signature##_g->get(); \ 137 if (result) return *result; \ 138 result = new type(); \ 139 adobe_thread_local_storage_##signature##_g->reset(result); \ 143 #define ADOBE_THREAD_LOCAL_STORAGE_INITIALIZE(signature) \ 144 static adobe_thread_local_storage_##signature##_t adobe_thread_local_storage_##signature##_s; \ 145 adobe_thread_local_storage_##signature##_g = &adobe_thread_local_storage_##signature##_s 149 #define ADOBE_THREAD_LOCAL_STORAGE_1(type, signature, ctor_p1) \ 150 type& adobe_thread_local_storage_##signature##_access(); \ 151 type& adobe_thread_local_storage_##signature##_access() \ 153 static type adobe_thread_local_storage_##signature##_s(ctor_p1); \ 154 return adobe_thread_local_storage_##signature##_s; \ 157 #define ADOBE_THREAD_LOCAL_STORAGE(type, signature) \ 158 type& adobe_thread_local_storage_##signature##_access(); \ 159 type& adobe_thread_local_storage_##signature##_access() \ 161 static type adobe_thread_local_storage_##signature##_s; \ 162 return adobe_thread_local_storage_##signature##_s; \ 165 #define ADOBE_THREAD_LOCAL_STORAGE_INITIALIZE(signature) 169 #define ADOBE_THREAD_LOCAL_STORAGE_ACCESS(signature) \ 170 adobe_thread_local_storage_##signature##_access() 174 #endif // ADOBE_ONCE_HPP
void call_once(void(*func)(), adobe::once_flag &flag)
|