log4cpp
1.1.6
Toggle main menu visibility
Loading...
Searching...
No Matches
BoostThreads.hh
Go to the documentation of this file.
1
/*
2
* BoostThreads.hh
3
*
4
* Copyright 2002, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
5
* Copyright 2002, Bastiaan Bakker. All rights reserved.
6
*
7
* See the COPYING file for the terms of usage and distribution.
8
*/
9
10
#ifndef _LOG4CPP_THREADING_BOOSTTHREADS_HH
11
#define _LOG4CPP_THREADING_BOOSTTHREADS_HH
12
13
#include <boost/thread/mutex.hpp>
14
#include <boost/thread/thread.hpp>
15
#include <boost/thread/tss.hpp>
16
#include <cstdio>
17
#include <
log4cpp/Portability.hh
>
18
#include <string>
19
20
namespace
log4cpp
{
21
namespace
threading
{
22
static
std::string
getThreadId
() {
23
char
buffer[14];
24
// Boost.Threads stores the thread ID but doesn't expose it
25
sprintf(buffer,
"not available"
);
26
return
std::string(buffer);
27
};
28
29
typedef
boost::mutex
Mutex
;
30
typedef
boost::mutex::scoped_lock
ScopedLock
;
31
32
template
<
typename
T>
class
ThreadLocalDataHolder
{
33
public
:
34
inline
T*
get
()
const
{
35
return
_localData.get();
36
};
37
38
inline
T*
operator->
()
const
{
39
return
_localData.get();
40
};
41
inline
T&
operator*
()
const
{
42
return
*_localData.get();
43
};
44
45
inline
T*
release
() {
46
return
_localData.release();
47
};
48
49
inline
void
reset
(T* p = NULL) {
50
_localData.reset(p);
51
};
52
53
private
:
54
boost::thread_specific_ptr<T> _localData;
55
};
56
57
}
// namespace threading
58
}
// namespace log4cpp
59
#endif
Portability.hh
log4cpp::threading::Mutex
Definition
PThreads.hh:28
log4cpp::threading::ScopedLock
definition of ScopedLock;
Definition
PThreads.hh:57
log4cpp::threading::ThreadLocalDataHolder::ThreadLocalDataHolder
ThreadLocalDataHolder()
Definition
DummyThreads.hh:36
log4cpp::threading::ThreadLocalDataHolder::operator->
T * operator->() const
Definition
BoostThreads.hh:38
log4cpp::threading::ThreadLocalDataHolder::operator*
T & operator*() const
Definition
BoostThreads.hh:41
log4cpp::threading::ThreadLocalDataHolder::get
T * get() const
Definition
BoostThreads.hh:34
log4cpp::threading::ThreadLocalDataHolder::reset
void reset(T *p=NULL)
Definition
BoostThreads.hh:49
log4cpp::threading::ThreadLocalDataHolder::release
T * release()
Definition
BoostThreads.hh:45
log4cpp::threading
Definition
BoostThreads.hh:21
log4cpp::threading::getThreadId
static std::string getThreadId()
Return an identifier for the current thread.
Definition
BoostThreads.hh:22
log4cpp
The top level namespace for all 'Log for C++' types and classes.
Definition
AbortAppender.hh:16
include
log4cpp
threading
BoostThreads.hh
Generated by
1.17.0