Loading...
Searching...
No Matches
BoostThreads.hh
Go to the documentation of this file.
/*
* BoostThreads.hh
*
* Copyright 2002, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
* Copyright 2002, Bastiaan Bakker. All rights reserved.
*
* See the COPYING file for the terms of usage and distribution.
*/
#ifndef _LOG4SHIB_THREADING_BOOSTTHREADS_HH
#define _LOG4SHIB_THREADING_BOOSTTHREADS_HH
#include <log4shib/Portability.hh>
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/tss.hpp>
#include <cstdio>
#include <string>
namespace log4shib {
namespace threading {
static std::string getThreadId() {
char buffer[14];
// Boost.Threads stores the thread ID but doesn't expose it
sprintf(buffer, "not available");
return std::string(buffer);
};
typedef boost::mutex Mutex;
typedef boost::mutex::scoped_lock ScopedLock;
template<typename T> class ThreadLocalDataHolder {
public:
inline T* get() const {
return _localData.get();
};
inline T* operator->() const { return _localData.get(); };
inline T& operator*() const { return *_localData.get(); };
inline T* release() {
return _localData.release();
};
inline void reset(T* p = NULL) {
_localData.reset(p);
};
private:
boost::thread_specific_ptr<T> _localData;
};
}
}
#endif
Portability.hh
log4shib::threading::Mutex
Definition PThreads.hh:29
log4shib::threading::ScopedLock
definition of ScopedLock;
Definition PThreads.hh:58
log4shib::threading::ThreadLocalDataHolder::operator->
T * operator->() const
Definition BoostThreads.hh:38
log4shib::threading::ThreadLocalDataHolder::operator*
T & operator*() const
Definition BoostThreads.hh:39
log4shib::threading::ThreadLocalDataHolder::reset
void reset(T *p=NULL)
Definition BoostThreads.hh:45
log4shib::threading::ThreadLocalDataHolder::get
T * get() const
Definition BoostThreads.hh:34
log4shib::threading::ThreadLocalDataHolder::release
T * release()
Definition BoostThreads.hh:41
log4shib::threading::ThreadLocalDataHolder::ThreadLocalDataHolder
ThreadLocalDataHolder()
Definition DummyThreads.hh:36
log4shib::threading
Definition BoostThreads.hh:21
log4shib::threading::getThreadId
static std::string getThreadId()
Return an identifier for the current thread.
Definition BoostThreads.hh:22
log4shib
The top level namespace for all 'Log for C++' types and classes.
Definition AbortAppender.hh:16