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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>log4cpp: BoostThreads.hh Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.2 -->
<div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a> | <a class="qindex" href="pages.html">Related Pages</a></div>
<div class="nav">
<a class="el" href="dir_000001.html">include</a> / <a class="el" href="dir_000002.html">log4cpp</a> / <a class="el" href="dir_000003.html">threading</a></div>
<h1>BoostThreads.hh</h1><a href="BoostThreads_8hh.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/*</span>
00002 <span class="comment"> * BoostThreads.hh</span>
00003 <span class="comment"> *</span>
00004 <span class="comment"> * Copyright 2002, LifeLine Networks BV (www.lifeline.nl). All rights reserved.</span>
00005 <span class="comment"> * Copyright 2002, Bastiaan Bakker. All rights reserved.</span>
00006 <span class="comment"> *</span>
00007 <span class="comment"> * See the COPYING file for the terms of usage and distribution.</span>
00008 <span class="comment"> */</span>
00009
00010 <span class="preprocessor">#ifndef _LOG4CPP_THREADING_BOOSTTHREADS_HH</span>
00011 <span class="preprocessor"></span><span class="preprocessor">#define _LOG4CPP_THREADING_BOOSTTHREADS_HH</span>
00012 <span class="preprocessor"></span>
00013 <span class="preprocessor">#include <<a class="code" href="Portability_8hh.html">log4cpp/Portability.hh</a>></span>
00014 <span class="preprocessor">#include <boost/thread/thread.hpp></span>
00015 <span class="preprocessor">#include <boost/thread/mutex.hpp></span>
00016 <span class="preprocessor">#include <boost/thread/tss.hpp></span>
00017 <span class="preprocessor">#include <cstdio></span>
00018 <span class="preprocessor">#include <string></span>
00019
00020 <span class="keyword">namespace </span>log4cpp {
<a name="l00021"></a><a class="code" href="namespacelog4cpp_1_1threading.html">00021</a> <span class="keyword">namespace </span>threading {
<a name="l00022"></a><a class="code" href="namespacelog4cpp_1_1threading.html#a2">00022</a> <span class="keyword">static</span> std::string <a class="code" href="namespacelog4cpp_1_1threading.html#a2">getThreadId</a>() {
00023 <span class="keywordtype">char</span> buffer[14];
00024 <span class="comment">// Boost.Threads stores the thread ID but doesn't expose it</span>
00025 sprintf(buffer, <span class="stringliteral">"not available"</span>);
00026 <span class="keywordflow">return</span> std::string(buffer);
<a name="l00027"></a><a class="code" href="namespacelog4cpp_1_1threading.html#a0">00027</a> };
00028
00029 <span class="keyword">typedef</span> boost::mutex <a class="code" href="namespacelog4cpp_1_1threading.html#a0">Mutex</a>;
<a name="l00030"></a><a class="code" href="namespacelog4cpp_1_1threading.html#a1">00030</a> <span class="keyword">typedef</span> boost::mutex::scoped_lock <a class="code" href="classlog4cpp_1_1threading_1_1ScopedLock.html">ScopedLock</a>;
00031
<a name="l00032"></a><a class="code" href="classlog4cpp_1_1threading_1_1ThreadLocalDataHolder.html">00032</a> <span class="keyword">template</span><<span class="keyword">typename</span> T> <span class="keyword">class </span><a class="code" href="classlog4cpp_1_1threading_1_1ThreadLocalDataHolder.html">ThreadLocalDataHolder</a> {
00033 <span class="keyword">public</span>:
<a name="l00034"></a><a class="code" href="classlog4cpp_1_1threading_1_1ThreadLocalDataHolder.html#a0">00034</a> <span class="keyword">inline</span> T* <a class="code" href="classlog4cpp_1_1threading_1_1ThreadLocalDataHolder.html#a0">get</a>()<span class="keyword"> const </span>{
00035 <span class="keywordflow">return</span> _localData.get();
00036 };
00037
<a name="l00038"></a><a class="code" href="classlog4cpp_1_1threading_1_1ThreadLocalDataHolder.html#a1">00038</a> <span class="keyword">inline</span> T* <a class="code" href="classlog4cpp_1_1threading_1_1ThreadLocalDataHolder.html#a1">operator-></a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _localData.get(); };
<a name="l00039"></a><a class="code" href="classlog4cpp_1_1threading_1_1ThreadLocalDataHolder.html#a2">00039</a> <span class="keyword">inline</span> T& operator*()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> *_localData.get(); };
00040
<a name="l00041"></a><a class="code" href="classlog4cpp_1_1threading_1_1ThreadLocalDataHolder.html#a3">00041</a> <span class="keyword">inline</span> T* <a class="code" href="classlog4cpp_1_1threading_1_1ThreadLocalDataHolder.html#a3">release</a>() {
00042 <span class="keywordflow">return</span> _localData.release();
00043 };
00044
<a name="l00045"></a><a class="code" href="classlog4cpp_1_1threading_1_1ThreadLocalDataHolder.html#a4">00045</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classlog4cpp_1_1threading_1_1ThreadLocalDataHolder.html#a4">reset</a>(T* p = NULL) {
00046 _localData.reset(p);
00047 };
00048
00049 <span class="keyword">private</span>:
00050 boost::thread_specific_ptr<T> _localData;
00051 };
00052
00053 }
00054 }
00055 <span class="preprocessor">#endif</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri Jul 29 14:07:33 2005 for log4cpp by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.2 </small></address>
</body>
</html>
|