Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _LOG4CPP_THREADING_BOOSTTHREADS_HH
00011 #define _LOG4CPP_THREADING_BOOSTTHREADS_HH
00012
00013 #include <log4cpp/Portability.hh>
00014 #include <boost/thread/thread.hpp>
00015 #include <boost/thread/mutex.hpp>
00016 #include <boost/thread/tss.hpp>
00017 #include <cstdio>
00018 #include <string>
00019
00020 namespace log4cpp {
00021 namespace threading {
00022 static std::string getThreadId() {
00023 char buffer[14];
00024
00025 sprintf(buffer, "not available");
00026 return std::string(buffer);
00027 };
00033 static char* getThreadId(char* buffer) {
00034
00035 sprintf(buffer, "not available");
00036 return buffer;
00037 };
00038
00039 typedef boost::mutex Mutex;
00040 typedef boost::mutex::scoped_lock ScopedLock;
00041
00042 template<typename T> class ThreadLocalDataHolder {
00043 public:
00044 inline T* get() const {
00045 return _localData.get();
00046 };
00047
00048 inline T* operator->() const { return _localData.get(); };
00049 inline T& operator*() const { return *_localData.get(); };
00050
00051 inline T* release() {
00052 return _localData.release();
00053 };
00054
00055 inline void reset(T* p = NULL) {
00056 _localData.reset(p);
00057 };
00058
00059 private:
00060 boost::thread_specific_ptr<T> _localData;
00061 };
00062
00063 }
00064 }
00065 #endif
log4cpp
Author(s): Stephen Roderick, Bastiaan Bakker, Cedric Le Goater, Steve Ostlind, Marcel Harkema, Walter Stroebel, Glenn Scott and Tony Cheung.
autogenerated on Thu Jan 2 2014 11:35:02