28 #ifndef _LOG4TANGO_THREADING_PTHREADS_H
29 #define _LOG4TANGO_THREADING_PTHREADS_H
51 pthread_mutex_t mutex;
56 ::pthread_mutex_init(&mutex, NULL);
60 ::pthread_mutex_destroy(&mutex);
64 ::pthread_mutex_lock(&mutex);
68 ::pthread_mutex_unlock(&mutex);
108 int lock (
long timeout_ = 0);
128 long recursion_level_;
141 #ifdef LOG4TANGO_HAS_NDC
142 template<
typename T>
class ThreadLocalDataHolder {
150 inline ThreadLocalDataHolder() {
151 ::pthread_key_create(&_key, freeHolder);
154 inline static void freeHolder(
void *p) {
156 delete reinterpret_cast<T *
>(p);
159 inline ~ThreadLocalDataHolder() {
164 ::pthread_key_delete(_key);
167 inline T*
get()
const {
168 return reinterpret_cast<T *
>(::pthread_getspecific(_key));
171 inline T* operator->()
const {
return get(); }
172 inline T& operator*()
const {
return *
get(); }
174 inline T* release() {
176 ::pthread_setspecific(_key, NULL);
180 inline void reset(T* p = NULL) {
185 ::pthread_setspecific(_key, p);
188 #endif //LOG4TANGO_HAS_NDC
194 #endif // _LOG4TANGO_THREADING_PTHREADS_H