123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- /*
- * DummyThreads.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 _LOG4CPP_THREADING_DUMMYTHREADS_HH
- #define _LOG4CPP_THREADING_DUMMYTHREADS_HH
- #include <log4cpp/Portability.hh>
- #include <stdio.h>
- #include <string>
- LOG4CPP_NS_BEGIN
- namespace threading {
- std::string getThreadId();
- /**
- Dummy type 'int' for Mutex. Yes, this adds a bit of overhead in
- the for of extra memory, but unfortunately 'void' is illegal.
- **/
- typedef int Mutex;
- /**
- Dummy type 'int' defintion of ScopedLock;
- **/
- typedef int ScopedLock;
- template<typename T> class ThreadLocalDataHolder {
- public:
- typedef T data_type;
- inline ThreadLocalDataHolder() {};
- inline ~ThreadLocalDataHolder() {
- if (_data)
- delete _data;
- };
- inline T* get() const {
- return _data;
- };
- inline T* operator->() const { return get(); };
- inline T& operator*() const { return *get(); };
- inline T* release() {
- T* result = _data;
- _data = NULL;
- return result;
- };
- inline void reset(T* p = NULL) {
- if (_data)
- delete _data;
- _data = p;
- };
- private:
- T* _data;
- };
- }
- LOG4CPP_NS_END
- #endif
|