# 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         std::string getThreadId();
    00020
    00025         typedef int Mutex;
    00026
    00030         typedef int ScopedLock;
    00031
    00032         template<typename T> class ThreadLocalDataHolder {
    00033             public:
    00034             typedef T data_type;
    00035
    00036             inline ThreadLocalDataHolder() {};
    00037             inline ~ThreadLocalDataHolder() {
    00038                 if (_data)
    00039                     delete _data;
    00040             };
    00041
    00042             inline T* get() const {
    00043                 return _data;
    00044             };
    00045
    00046             inline T* operator->() const { return get(); };
    00047             inline T& operator*() const { return *get(); };
    00048
    00049             inline T* release() {
    00050                 T* result = _data;
    00051                 _data = NULL;
    00052
    00053                 return result;
    00054             };
    00055
    00056             inline void reset(T* p = NULL) {
    00057                 if (_data)
    00058                     delete _data;
    00059                 _data = p;
    00060             };
    00061
    00062             private:
    00063             T* _data;
    00064         };
    00065     }
    00066 }
    00067 #endif