BoostThreads.hh
Go to the documentation of this file.
00001 /*
00002  * BoostThreads.hh
00003  *
00004  * Copyright 2002, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
00005  * Copyright 2002, Bastiaan Bakker. All rights reserved.
00006  *
00007  * See the COPYING file for the terms of usage and distribution.
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             // Boost.Threads stores the thread ID but doesn't expose it
00025             sprintf(buffer, "not available");
00026             return std::string(buffer);
00027         };
00033         static char* getThreadId(char* buffer) {
00034             // Boost.Threads stores the thread ID but doesn't expose it
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 Sat Jun 8 2019 18:45:46