Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

DummyThreads.hh

Go to the documentation of this file.
00001 /*
00002  * DummyThreads.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_DUMMYTHREADS_HH
00011 #define _LOG4CPP_THREADING_DUMMYTHREADS_HH
00012 
00013 #include <log4cpp/Portability.hh>
00014 #include <stdio.h>
00015 #include <string>
00016 
00017 namespace log4cpp {
00018     namespace threading {
00019         static std::string getThreadId() {
00020             // more useful would be to return the PID.
00021             return std::string("thread1");
00022         };
00023         
00028         typedef int Mutex;
00029 
00033         typedef int ScopedLock;
00034 
00035         template<typename T> class ThreadLocalDataHolder {
00036             public:
00037             typedef T data_type;
00038 
00039             inline ThreadLocalDataHolder() {};
00040             inline ~ThreadLocalDataHolder() {
00041                 if (_data) 
00042                     delete _data;
00043             };
00044             
00045             inline T* get() const {
00046                 return _data;
00047             };
00048 
00049             inline T* operator->() const { return get(); };
00050             inline T& operator*() const { return *get(); };
00051 
00052             inline T* release() {
00053                 T* result = _data;
00054                 _data = NULL;
00055 
00056                 return result;
00057             };
00058 
00059             inline void reset(T* p = NULL) {
00060                 if (_data) 
00061                     delete _data;
00062                 _data = p;
00063             };
00064 
00065             private:            
00066             T* _data;            
00067         };
00068     }
00069 }
00070 #endif

Generated on Thu Aug 15 00:00:20 2002 for log4cpp by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002