BoostThreads.hh
Go to the documentation of this file.
1 /*
2  * BoostThreads.hh
3  *
4  * Copyright 2002, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
5  * Copyright 2002, Bastiaan Bakker. All rights reserved.
6  *
7  * See the COPYING file for the terms of usage and distribution.
8  */
9 
10 #ifndef _LOG4CPP_THREADING_BOOSTTHREADS_HH
11 #define _LOG4CPP_THREADING_BOOSTTHREADS_HH
12 
13 #include <log4cpp/Portability.hh>
14 #include <boost/thread/thread.hpp>
15 #include <boost/thread/mutex.hpp>
16 #include <boost/thread/tss.hpp>
17 #include <cstdio>
18 #include <string>
19 
20 namespace log4cpp {
21  namespace threading {
22  static std::string getThreadId() {
23  char buffer[14];
24  // Boost.Threads stores the thread ID but doesn't expose it
25  sprintf(buffer, "not available");
26  return std::string(buffer);
27  };
33  static char* getThreadId(char* buffer) {
34  // Boost.Threads stores the thread ID but doesn't expose it
35  sprintf(buffer, "not available");
36  return buffer;
37  };
38 
39  typedef boost::mutex Mutex;
40  typedef boost::mutex::scoped_lock ScopedLock;
41 
42  template<typename T> class ThreadLocalDataHolder {
43  public:
44  inline T* get() const {
45  return _localData.get();
46  };
47 
48  inline T* operator->() const { return _localData.get(); };
49  inline T& operator*() const { return *_localData.get(); };
50 
51  inline T* release() {
52  return _localData.release();
53  };
54 
55  inline void reset(T* p = NULL) {
56  _localData.reset(p);
57  };
58 
59  private:
60  boost::thread_specific_ptr<T> _localData;
61  };
62 
63  }
64 }
65 #endif
static std::string getThreadId()
Definition: BoostThreads.hh:22
boost::mutex Mutex
Definition: BoostThreads.hh:37
boost::thread_specific_ptr< T > _localData
Definition: BoostThreads.hh:57
boost::mutex::scoped_lock ScopedLock
Definition: BoostThreads.hh:40


log4cpp
Author(s): Stephen Roderick, Bastiaan Bakker, Cedric Le Goater, Steve Ostlind, Marcel Harkema, Walter Stroebel, Glenn Scott and Tony Cheung
autogenerated on Sun Jun 23 2019 19:14:17