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 77 78 79 80 81 82
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>log4cpp: BoostThreads.hh Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.2 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File List</span></a></li>
<li><a href="globals.html"><span>File Members</span></a></li>
</ul>
</div>
<h1>BoostThreads.hh</h1><a href="BoostThreads_8hh.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * BoostThreads.hh</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * Copyright 2002, LifeLine Networks BV (www.lifeline.nl). All rights reserved.</span>
<a name="l00005"></a>00005 <span class="comment"> * Copyright 2002, Bastiaan Bakker. All rights reserved.</span>
<a name="l00006"></a>00006 <span class="comment"> *</span>
<a name="l00007"></a>00007 <span class="comment"> * See the COPYING file for the terms of usage and distribution.</span>
<a name="l00008"></a>00008 <span class="comment"> */</span>
<a name="l00009"></a>00009
<a name="l00010"></a>00010 <span class="preprocessor">#ifndef _LOG4CPP_THREADING_BOOSTTHREADS_HH</span>
<a name="l00011"></a>00011 <span class="preprocessor"></span><span class="preprocessor">#define _LOG4CPP_THREADING_BOOSTTHREADS_HH</span>
<a name="l00012"></a>00012 <span class="preprocessor"></span>
<a name="l00013"></a>00013 <span class="preprocessor">#include <<a class="code" href="Portability_8hh.html">log4cpp/Portability.hh</a>></span>
<a name="l00014"></a>00014 <span class="preprocessor">#include <boost/thread/thread.hpp></span>
<a name="l00015"></a>00015 <span class="preprocessor">#include <boost/thread/mutex.hpp></span>
<a name="l00016"></a>00016 <span class="preprocessor">#include <boost/thread/tss.hpp></span>
<a name="l00017"></a>00017 <span class="preprocessor">#include <cstdio></span>
<a name="l00018"></a>00018 <span class="preprocessor">#include <string></span>
<a name="l00019"></a>00019
<a name="l00020"></a>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#f2f7960b92e64a8beb0dcb08ee6bf378">00022</a> <span class="keyword">static</span> std::string <a class="code" href="namespacelog4cpp_1_1threading.html#f2f7960b92e64a8beb0dcb08ee6bf378" title="returns the thread ID">getThreadId</a>() {
<a name="l00023"></a>00023 <span class="keywordtype">char</span> buffer[14];
<a name="l00024"></a>00024 <span class="comment">// Boost.Threads stores the thread ID but doesn't expose it</span>
<a name="l00025"></a>00025 sprintf(buffer, <span class="stringliteral">"not available"</span>);
<a name="l00026"></a>00026 <span class="keywordflow">return</span> std::string(buffer);
<a name="l00027"></a><a class="code" href="namespacelog4cpp_1_1threading.html#5a9f591b9fac01362c5bf99b715d6ede">00027</a> };
<a name="l00028"></a>00028
<a name="l00029"></a>00029 <span class="keyword">typedef</span> boost::mutex <a class="code" href="namespacelog4cpp_1_1threading.html#5a9f591b9fac01362c5bf99b715d6ede">Mutex</a>;
<a name="l00030"></a><a class="code" href="namespacelog4cpp_1_1threading.html#aec64dd75883664a19f8e55ce6288e9c">00030</a> <span class="keyword">typedef</span> boost::mutex::scoped_lock <a class="code" href="classlog4cpp_1_1threading_1_1ScopedLock.html" title="definition of ScopedLock;">ScopedLock</a>;
<a name="l00031"></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" title="This class holds Thread local data of type T, i.e.">ThreadLocalDataHolder</a> {
<a name="l00033"></a>00033 <span class="keyword">public</span>:
<a name="l00034"></a><a class="code" href="classlog4cpp_1_1threading_1_1ThreadLocalDataHolder.html#147cbba1fab8ef3eec6d98ef122749b1">00034</a> <span class="keyword">inline</span> T* <span class="keyword">get</span>() <span class="keyword">const</span> {
<a name="l00035"></a>00035 <span class="keywordflow">return</span> _localData.get();
<a name="l00036"></a>00036 };
<a name="l00037"></a>00037
<a name="l00038"></a><a class="code" href="classlog4cpp_1_1threading_1_1ThreadLocalDataHolder.html#f579e5a7fdcba839bf8d95f2ede8a43e">00038</a> <span class="keyword">inline</span> T* <a class="code" href="classlog4cpp_1_1threading_1_1ThreadLocalDataHolder.html#f579e5a7fdcba839bf8d95f2ede8a43e">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#e97fc1f8d6f9c8b11d94c5e213249dbd">00039</a> <span class="keyword">inline</span> T& <a class="code" href="classlog4cpp_1_1threading_1_1ThreadLocalDataHolder.html#e97fc1f8d6f9c8b11d94c5e213249dbd">operator*</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> *_localData.get(); };
<a name="l00040"></a>00040
<a name="l00041"></a><a class="code" href="classlog4cpp_1_1threading_1_1ThreadLocalDataHolder.html#299e9e1f9e02ef2668e64f81b1d29204">00041</a> <span class="keyword">inline</span> T* <a class="code" href="classlog4cpp_1_1threading_1_1ThreadLocalDataHolder.html#299e9e1f9e02ef2668e64f81b1d29204">release</a>() {
<a name="l00042"></a>00042 <span class="keywordflow">return</span> _localData.release();
<a name="l00043"></a>00043 };
<a name="l00044"></a>00044
<a name="l00045"></a><a class="code" href="classlog4cpp_1_1threading_1_1ThreadLocalDataHolder.html#e45b1bbee63188f40ed0a1fd262903dc">00045</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classlog4cpp_1_1threading_1_1ThreadLocalDataHolder.html#e45b1bbee63188f40ed0a1fd262903dc">reset</a>(T* p = NULL) {
<a name="l00046"></a>00046 _localData.reset(p);
<a name="l00047"></a>00047 };
<a name="l00048"></a>00048
<a name="l00049"></a>00049 <span class="keyword">private</span>:
<a name="l00050"></a>00050 boost::thread_specific_ptr<T> _localData;
<a name="l00051"></a>00051 };
<a name="l00052"></a>00052
<a name="l00053"></a>00053 }
<a name="l00054"></a>00054 }
<a name="l00055"></a>00055 <span class="preprocessor">#endif</span>
</pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Mon Sep 3 11:54:29 2007 for log4cpp by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.2 </small></address>
</body>
</html>
|