| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> |
| <title>oscl_tls.h Source File</title> |
| <link href="doxygen.css" rel="stylesheet" type="text/css"> |
| </head><body> |
| <!-- Generated by Doxygen 1.2.18 --> |
| <center> |
| <a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="modules.html">Modules</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Data Structures</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Data Fields</a> <a class="qindex" href="globals.html">Globals</a> </center> |
| <hr><h1>oscl_tls.h</h1><a href="oscl__tls_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">// -*- c++ -*-</span> |
| 00002 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span> |
| 00003 |
| 00004 <span class="comment">// O S C L _ T L S</span> |
| 00005 |
| 00006 <span class="comment">// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =</span> |
| 00007 |
| 00022 <span class="preprocessor">#ifndef OSCL_TLS_H_INCLUDED</span> |
| 00023 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_TLS_H_INCLUDED</span> |
| 00024 <span class="preprocessor"></span> |
| 00025 <span class="preprocessor">#ifndef OSCL_BASE_H_INCLUDED</span> |
| 00026 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__base_8h.html">oscl_base.h</a>"</span> |
| 00027 <span class="preprocessor">#endif</span> |
| 00028 <span class="preprocessor"></span> |
| 00029 <span class="preprocessor">#ifndef OSCL_DEFALLOC_H_INCLUDED</span> |
| 00030 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__defalloc_8h.html">oscl_defalloc.h</a>"</span> |
| 00031 <span class="preprocessor">#endif</span> |
| 00032 <span class="preprocessor"></span> |
| 00033 |
| 00034 <span class="preprocessor">#if (OSCL_TLS_IS_KEYED)</span> |
| 00035 <span class="preprocessor"></span> |
| 00036 <span class="comment">//Keyed TLS requires global variable support</span> |
| 00037 <span class="preprocessor">#else</span> |
| 00038 <span class="preprocessor"></span> |
| 00039 <span class="comment">//unused value.</span> |
| <a name="l00040"></a><a class="code" href="group__osclbase.html#a10">00040</a> <span class="keyword">typedef</span> <a class="code" href="group__osclbase.html#a25">OsclAny</a> <a class="code" href="group__osclbase.html#a10">TOsclTlsKey</a>; |
| 00041 |
| 00042 <span class="preprocessor">#endif //OSCL_TLS_IS_KEYED</span> |
| 00043 <span class="preprocessor"></span> |
| 00044 |
| 00045 <span class="comment">// list of TLS objects</span> |
| <a name="l00046"></a><a class="code" href="group__osclbase.html#a11">00046</a> <span class="keyword">const</span> uint32 <a class="code" href="group__osclbase.html#a11">OSCL_TLS_ID_MAGICNUM</a> = 0; |
| <a name="l00047"></a><a class="code" href="group__osclbase.html#a12">00047</a> <span class="keyword">const</span> uint32 <a class="code" href="group__osclbase.html#a12">OSCL_TLS_ID_ERRORHOOK</a> = 1; |
| <a name="l00048"></a><a class="code" href="group__osclbase.html#a13">00048</a> <span class="keyword">const</span> uint32 <a class="code" href="group__osclbase.html#a13">OSCL_TLS_ID_PVLOGGER</a> = 2; |
| <a name="l00049"></a><a class="code" href="group__osclbase.html#a14">00049</a> <span class="keyword">const</span> uint32 <a class="code" href="group__osclbase.html#a14">OSCL_TLS_ID_TEST</a> = 3; |
| <a name="l00050"></a><a class="code" href="group__osclbase.html#a15">00050</a> <span class="keyword">const</span> uint32 <a class="code" href="group__osclbase.html#a15">OSCL_TLS_ID_PVSCHEDULER</a> = 4; |
| <a name="l00051"></a><a class="code" href="group__osclbase.html#a16">00051</a> <span class="keyword">const</span> uint32 <a class="code" href="group__osclbase.html#a16">OSCL_TLS_ID_PVERRORTRAP</a> = 5; |
| <a name="l00052"></a><a class="code" href="group__osclbase.html#a17">00052</a> <span class="keyword">const</span> uint32 <a class="code" href="group__osclbase.html#a17">OSCL_TLS_ID_SDPMEDIAPARSER</a> = 6; |
| <a name="l00053"></a><a class="code" href="group__osclbase.html#a18">00053</a> <span class="keyword">const</span> uint32 <a class="code" href="group__osclbase.html#a18">OSCL_TLS_ID_PAYLOADPARSER</a> = 7; |
| <a name="l00054"></a><a class="code" href="group__osclbase.html#a19">00054</a> <span class="keyword">const</span> uint32 <a class="code" href="group__osclbase.html#a19">OSCL_TLS_ID_PVMFRECOGNIZER</a> = 8; |
| <a name="l00055"></a><a class="code" href="group__osclbase.html#a20">00055</a> <span class="keyword">const</span> uint32 <a class="code" href="group__osclbase.html#a20">OSCL_TLS_ID_WMDRM</a> = 9; |
| <a name="l00056"></a><a class="code" href="group__osclbase.html#a21">00056</a> <span class="keyword">const</span> uint32 <a class="code" href="group__osclbase.html#a21">OSCL_TLS_ID_OSCLREGISTRY</a> = 10; |
| <a name="l00057"></a><a class="code" href="group__osclbase.html#a22">00057</a> <span class="keyword">const</span> uint32 <a class="code" href="group__osclbase.html#a22">OSCL_TLS_ID_SQLITE3</a> = 11; |
| <a name="l00058"></a><a class="code" href="group__osclbase.html#a23">00058</a> <span class="keyword">const</span> uint32 <a class="code" href="group__osclbase.html#a23">OSCL_TLS_ID_BASE_LAST</a> = 11; <span class="comment">// should always equal the largest ID defined here</span> |
| 00059 |
| <a name="l00060"></a><a class="code" href="group__osclbase.html#a106">00060</a> <span class="preprocessor">#define OSCL_TLS_BASE_SLOTS OSCL_TLS_ID_BASE_LAST +1</span> |
| 00061 <span class="preprocessor"></span> |
| 00062 <span class="comment">//There may be additional slots defined in the osclconfig.h for the build.</span> |
| 00063 <span class="preprocessor">#ifndef OSCL_TLS_EXTERNAL_SLOTS</span> |
| <a name="l00064"></a><a class="code" href="group__osclbase.html#a107">00064</a> <span class="preprocessor"></span><span class="preprocessor">#define OSCL_TLS_EXTERNAL_SLOTS 0</span> |
| 00065 <span class="preprocessor"></span><span class="preprocessor">#endif</span> |
| 00066 <span class="preprocessor"></span> |
| <a name="l00067"></a><a class="code" href="group__osclbase.html#a108">00067</a> <span class="preprocessor">#define OSCL_TLS_MAX_SLOTS ( OSCL_TLS_BASE_SLOTS + OSCL_TLS_EXTERNAL_SLOTS)</span> |
| 00068 <span class="preprocessor"></span> |
| <a name="l00069"></a><a class="code" href="classTLSStorageOps.html">00069</a> <span class="keyword">class </span><a class="code" href="classTLSStorageOps.html">TLSStorageOps</a> |
| 00070 { |
| 00071 <span class="keyword">public</span>: |
| 00072 OSCL_IMPORT_REF <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classTLSStorageOps.html#d0">save_registry</a>(<a class="code" href="group__osclbase.html#a10">TOsclTlsKey</a>* key, <a class="code" href="group__osclbase.html#a25">OsclAny</a>* ptr, int32&); |
| 00073 OSCL_IMPORT_REF <span class="keyword">static</span> <a class="code" href="group__osclbase.html#a25">OsclAny</a>* <a class="code" href="classTLSStorageOps.html#d1">get_registry</a>(<a class="code" href="group__osclbase.html#a10">TOsclTlsKey</a>* key); |
| 00074 }; |
| 00075 |
| <a name="l00076"></a><a class="code" href="classOsclTLSRegistry.html">00076</a> <span class="keyword">class </span><a class="code" href="classOsclTLSRegistry.html">OsclTLSRegistry</a> |
| 00077 { |
| 00078 <span class="keyword">public</span>: |
| 00079 <span class="comment">/*</span> |
| 00080 <span class="comment"> ** Get an entry</span> |
| 00081 <span class="comment"> ** @param ID: identifier</span> |
| 00082 <span class="comment"> ** @param error (output) 0 for success or an error from TPVBaseErrorEnum</span> |
| 00083 <span class="comment"> ** @returns: the entry value</span> |
| 00084 <span class="comment"> */</span> |
| 00085 OSCL_IMPORT_REF <span class="keyword">static</span> <a class="code" href="group__osclbase.html#a25">OsclAny</a>* <a class="code" href="classOsclTLSRegistry.html#d0">getInstance</a>(uint32 ID, int32 &error); |
| 00086 <span class="comment">/*</span> |
| 00087 <span class="comment"> ** Set an entry</span> |
| 00088 <span class="comment"> ** @param ID: identifier</span> |
| 00089 <span class="comment"> ** @param error (output) 0 for success or an error from TPVBaseErrorEnum</span> |
| 00090 <span class="comment"> ** @returns: the entry value</span> |
| 00091 <span class="comment"> */</span> |
| 00092 OSCL_IMPORT_REF <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classOsclTLSRegistry.html#d1">registerInstance</a>(<a class="code" href="group__osclbase.html#a25">OsclAny</a>* ptr, uint32 ID, int32 &error); |
| 00093 |
| 00094 <span class="keyword">private</span>: |
| 00095 <a class="code" href="classOsclTLSRegistry.html">OsclTLSRegistry</a>() |
| 00096 {} |
| 00097 <span class="keyword">typedef</span> <a class="code" href="group__osclbase.html#a25">OsclAny</a>* registry_type; |
| 00098 <span class="keyword">typedef</span> registry_type* registry_pointer_type; |
| 00099 |
| 00100 <span class="preprocessor">#if ( OSCL_TLS_IS_KEYED)</span> |
| 00101 <span class="preprocessor"></span> <span class="keyword">class </span>TlsKey |
| 00102 { |
| 00103 <span class="keyword">public</span>: |
| 00104 TlsKey(): iRefCnt(0), iOsclTlsKey(<a class="code" href="group__osclbase.html#a81">NULL</a>) |
| 00105 {} |
| 00106 _OsclBasicLock iLock; |
| 00107 uint32 iRefCnt; |
| 00108 <a class="code" href="group__osclbase.html#a10">TOsclTlsKey</a> *iOsclTlsKey; |
| 00109 }; |
| 00110 |
| 00111 <span class="comment">//The key is a global variable.</span> |
| 00112 <span class="keyword">static</span> TlsKey* iTlsKey; |
| 00113 <span class="preprocessor">#endif</span> |
| 00114 <span class="preprocessor"></span> |
| 00115 <span class="keyword">private</span>: |
| 00116 OSCL_IMPORT_REF <span class="keyword">static</span> <span class="keywordtype">void</span> initialize(<a class="code" href="classOscl__DefAlloc.html">Oscl_DefAlloc</a> &alloc, int32 &error); |
| 00117 OSCL_IMPORT_REF <span class="keyword">static</span> <span class="keywordtype">void</span> cleanup(<a class="code" href="classOscl__DefAlloc.html">Oscl_DefAlloc</a> &alloc, int32 &error); |
| <a name="l00118"></a><a class="code" href="classOsclTLSRegistry.html#l0">00118</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classOsclTLSRegistry.html#l0">OsclBase</a>; |
| 00119 |
| 00120 }; |
| <a name="l00121"></a><a class="code" href="classOsclTLS.html">00121</a> |
| 00122 <span class="keyword">template</span> < <span class="keyword">class</span> T, u<span class="keywordtype">int</span>32 ID, <span class="keyword">class</span> Registry = OsclTLSRegistry > <span class="keyword">class </span><a class="code" href="classOsclTLS.html">OsclTLS</a> |
| 00123 { |
| 00124 <span class="keyword">private</span>: |
| 00125 <span class="comment">// make the copy constructor and assignment operator private</span> |
| 00126 <a class="code" href="classOsclTLS.html">OsclTLS</a>& operator=(<a class="code" href="classOsclTLS.html">OsclTLS</a>& _Y) |
| 00127 { |
| 00128 <span class="keywordflow">return</span>(*this); |
| 00129 } |
| 00130 |
| <a name="l00131"></a><a class="code" href="classOsclTLS.html#n0">00131</a> <span class="keyword">protected</span>: |
| 00132 T* <a class="code" href="classOsclTLS.html#n0">_Ptr</a>; |
| 00133 |
| <a name="l00134"></a><a class="code" href="classOsclTLS.html#a0">00134</a> <span class="keyword">public</span>: |
| 00135 <a class="code" href="classOsclTLS.html#a0">OsclTLS</a>() |
| 00136 { |
| 00137 int32 err; |
| 00138 <a class="code" href="classOsclTLS.html#n0">_Ptr</a> = <a class="code" href="group__osclbase.html#a86">OSCL_STATIC_CAST</a>(T*, Registry::getInstance(ID, err)); |
| 00139 } |
| <a name="l00140"></a><a class="code" href="classOsclTLS.html#a1">00140</a> |
| 00141 <a class="code" href="classOsclTLS.html#a1">~OsclTLS</a>() {}; |
| 00142 |
| 00150 T& <a class="code" href="classOsclTLS.html#a2">operator*</a>()<span class="keyword"> const</span> |
| 00151 <span class="keyword"> </span>{ |
| 00152 <span class="keywordflow">return</span>(*_Ptr); |
| 00153 } |
| 00154 |
| 00162 T *<a class="code" href="classOsclTLS.html#a3">operator-></a>()<span class="keyword"> const</span> |
| 00163 <span class="keyword"> </span>{ |
| 00164 <span class="keywordflow">return</span>(_Ptr); |
| 00165 } |
| 00166 |
| 00167 |
| 00174 <span class="keywordtype">bool</span> <a class="code" href="classOsclTLS.html#a4">set</a>() |
| 00175 { |
| 00176 int32 err; |
| 00177 <a class="code" href="classOsclTLS.html#n0">_Ptr</a> = <a class="code" href="group__osclbase.html#a86">OSCL_STATIC_CAST</a>(T*, Registry::getInstance(ID, err)); |
| 00178 <span class="keywordflow">return</span> (<a class="code" href="classOsclTLS.html#n0">_Ptr</a> ? <span class="keyword">true</span> : <span class="keyword">false</span>); |
| 00179 } |
| 00180 |
| 00181 }; |
| 00182 |
| 00187 <span class="preprocessor">#endif</span> |
| 00188 <span class="preprocessor"></span> |
| </pre></div><hr size="1"><img src="pvlogo_small.jpg"><address style="align: right;"><small>OSCL API</small> |
| <address style="align: left;"><small>Posting Version: OPENCORE_20090310 </small> |
| </small></address> |
| </body> |
| </html> |