log4tango
4.0.7
Main Page
Namespaces
Classes
Files
File List
File Members
lib
cpp
log4tango
include
log4tango
threading
DummyThreads.hh
Go to the documentation of this file.
1
//
2
// DummyThreads.hh
3
//
4
// Copyright (C) : 2000 - 2002
5
// LifeLine Networks BV (www.lifeline.nl). All rights reserved.
6
// Bastiaan Bakker. All rights reserved.
7
//
8
// 2004,2005,2006,2007,2008,2009,2010,2011,2012
9
// Synchrotron SOLEIL
10
// L'Orme des Merisiers
11
// Saint-Aubin - BP 48 - France
12
//
13
// This file is part of log4tango.
14
//
15
// Log4ango is free software: you can redistribute it and/or modify
16
// it under the terms of the GNU Lesser General Public License as published by
17
// the Free Software Foundation, either version 3 of the License, or
18
// (at your option) any later version.
19
//
20
// Log4tango is distributed in the hope that it will be useful,
21
// but WITHOUT ANY WARRANTY; without even the implied warranty of
22
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
// GNU Lesser General Public License for more details.
24
//
25
// You should have received a copy of the GNU Lesser General Public License
26
// along with Log4Tango. If not, see <http://www.gnu.org/licenses/>.
27
28
#ifndef _LOG4TANGO_THREADING_DUMMY_THREADS_H
29
#define _LOG4TANGO_THREADING_DUMMY_THREADS_H
30
31
#include <
log4tango/Portability.hh
>
32
#include <stdio.h>
33
#include <string>
34
35
namespace
log4tango {
36
37
namespace
threading {
38
39
std::string
get_thread_id
(
void
);
40
41
typedef
int
Mutex
;
42
43
typedef
int
ScopedLock
;
44
45
#ifdef LOG4TANGO_HAS_NDC
46
template
<
typename
T>
class
ThreadLocalDataHolder
47
{
48
public
:
49
typedef
T data_type;
50
51
inline
ThreadLocalDataHolder ()
52
: _data(0)
53
{
54
//no-op
55
};
56
57
inline
~ThreadLocalDataHolder () {
58
if
(_data) {
59
delete
_data;
60
}
61
};
62
63
inline
T*
get
(void)
const
{
64
return
_data;
65
};
66
67
inline
T* operator->()
const
{
68
return
get
();
69
};
70
71
inline
T& operator*()
const
{
72
return
*
get
();
73
};
74
75
inline
T* release() {
76
T* result = _data;
77
_data = 0;
78
return
result;
79
};
80
81
inline
void
reset (T* p = 0) {
82
if
(_data) {
83
delete
_data;
84
}
85
_data = p;
86
};
87
88
private
:
89
T* _data;
90
};
91
#endif // #ifdef LOG4TANGO_HAS_NDC
92
93
}
// namespace threading
94
95
}
// namespace log4tango
96
97
#endif // _LOG4TANGO_THREADING_DUMMY_THREADS_H
Generated on Wed May 29 2013 05:41:27 for log4tango by
1.8.3.1