admin
2022-08-18 67a5e3d825fde17b7b00906ce42b0bd8cafebc4e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 * 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>
 
namespace log4cpp {
    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;            
        };
    }
}
#endif