forked from orocos-toolchain/log4cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDummyThreads.hh
More file actions
76 lines (63 loc) · 1.97 KB
/
DummyThreads.hh
File metadata and controls
76 lines (63 loc) · 1.97 KB
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
68
69
70
71
72
73
74
75
76
/*
* 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();
/**
* Return an identifier for the current thread. What these
* identifiers look like is completely up to the underlying
* thread library. OmniThreads returns the POSIX thread Id.
*
* @param buffer Character buffer of at least 16 in size
* @return buffer
*/
char* getThreadId(char* buffer);
/**
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