1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> 3 <title>oscl_timer.h Source File</title> 4 <link href="doxygen.css" rel="stylesheet" type="text/css"> 5 </head><body> 6 <!-- Generated by Doxygen 1.2.18 --> 7 <center> 8 <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> 9 <hr><h1>oscl_timer.h</h1><a href="oscl__timer_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="preprocessor">#ifndef OSCL_TIMER_H_INCLUDED</span> 10 00002 <span class="preprocessor"></span><span class="preprocessor">#define OSCL_TIMER_H_INCLUDED</span> 11 00003 <span class="preprocessor"></span> 12 00004 <span class="preprocessor">#ifndef OSCL_BASE_H_INCLUDED</span> 13 00005 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__base_8h.html">oscl_base.h</a>"</span> 14 00006 <span class="preprocessor">#endif</span> 15 00007 <span class="preprocessor"></span> 16 00008 <span class="preprocessor">#ifndef OSCLCONFIG_UTIL_H_INCLUDED</span> 17 00009 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="osclconfig__util_8h.html">osclconfig_util.h</a>"</span> 18 00010 <span class="preprocessor">#endif</span> 19 00011 <span class="preprocessor"></span> 20 00012 <span class="preprocessor">#ifndef OSCL_VECTOR_H_INCLUDED</span> 21 00013 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__vector_8h.html">oscl_vector.h</a>"</span> 22 00014 <span class="preprocessor">#endif</span> 23 00015 <span class="preprocessor"></span> 24 00016 <span class="preprocessor">#ifndef OSCL_TICKCOUNT_H_INCLUDED</span> 25 00017 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__tickcount_8h.html">oscl_tickcount.h</a>"</span> 26 00018 <span class="preprocessor">#endif</span> 27 00019 <span class="preprocessor"></span> 28 00020 <span class="preprocessor">#ifndef OSCL_RAND_H_INCLUDED</span> 29 00021 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__rand_8h.html">oscl_rand.h</a>"</span> 30 00022 <span class="preprocessor">#endif</span> 31 00023 <span class="preprocessor"></span> 32 00024 <span class="preprocessor">#ifndef OSCL_SCHEDULER_AO_H_INCLUDED</span> 33 00025 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="oscl__scheduler__ao_8h.html">oscl_scheduler_ao.h</a>"</span> 34 00026 <span class="preprocessor">#endif</span> 35 00027 <span class="preprocessor"></span> 36 00028 37 <a name="l00032"></a><a class="code" href="classOsclTimerObserver.html">00032</a> <span class="keyword">class </span><a class="code" href="classOsclTimerObserver.html">OsclTimerObserver</a> 38 00033 { 39 00034 <span class="keyword">public</span>: 40 00043 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classOsclTimerObserver.html#a0">TimeoutOccurred</a>(int32 timerID, int32 timeoutInfo) = 0; 41 00044 42 <a name="l00045"></a><a class="code" href="classOsclTimerObserver.html#a1">00045</a> <span class="keyword">virtual</span> <a class="code" href="classOsclTimerObserver.html#a1">~OsclTimerObserver</a>() {} 43 00046 }; 44 00047 45 00053 <span class="keyword">template</span><<span class="keyword">class</span> Alloc> 46 00054 <span class="keyword">class </span><a class="code" href="classOsclTimer.html">OsclTimer</a> ; 47 00055 48 <a name="l00056"></a><a class="code" href="classCallbackTimerObserver.html">00056</a> <span class="keyword">class </span><a class="code" href="classCallbackTimerObserver.html">CallbackTimerObserver</a> 49 00057 { 50 00058 <span class="keyword">public</span>: 51 00059 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classCallbackTimerObserver.html#a0">TimerBaseElapsed</a>() = 0; 52 <a name="l00060"></a><a class="code" href="classCallbackTimerObserver.html#a1">00060</a> <span class="keyword">virtual</span> <a class="code" href="classCallbackTimerObserver.html#a1">~CallbackTimerObserver</a>() {} 53 00061 }; 54 00062 55 00063 <span class="keyword">template</span><<span class="keyword">class</span> Alloc> 56 <a name="l00064"></a><a class="code" href="classCallbackTimer.html">00064</a> <span class="keyword">class </span><a class="code" href="classCallbackTimer.html">CallbackTimer</a>: <span class="keyword">public</span> <a class="code" href="classOsclTimerObject.html">OsclTimerObject</a> 57 00065 { 58 00066 <span class="keyword">public</span>: 59 <a name="l00067"></a><a class="code" href="classCallbackTimer.html#a0">00067</a> <a class="code" href="classCallbackTimer.html#a0">CallbackTimer</a>(<a class="code" href="classCallbackTimerObserver.html">CallbackTimerObserver</a>& aContainer, <span class="keyword">const</span> <span class="keywordtype">char</span> *name, int32 aPriority = <a class="code" href="classOsclActiveObject.html#s5s2">OsclActiveObject::EPriorityNominal</a>) 60 00068 : <a class="code" href="classOsclTimerObject.html">OsclTimerObject</a>(aPriority, name) 61 00069 { 62 00070 iContainer = &aContainer; 63 00071 <a class="code" href="classOsclTimerObject.html#a2">AddToScheduler</a>(); 64 00072 } 65 <a name="l00073"></a><a class="code" href="classCallbackTimer.html#a1">00073</a> <a class="code" href="classCallbackTimer.html#a1">~CallbackTimer</a>() 66 00074 { 67 00075 <a class="code" href="classOsclTimerObject.html#a3">RemoveFromScheduler</a>(); 68 00076 } 69 <a name="l00077"></a><a class="code" href="classCallbackTimer.html#a2">00077</a> <span class="keywordtype">void</span> <a class="code" href="classCallbackTimer.html#a2">Run</a>() 70 00078 { 71 00079 <span class="keywordflow">if</span> (<a class="code" href="classOsclTimerObject.html#a10">Status</a>() == <a class="code" href="group__osclproc.html#a0">OSCL_REQUEST_ERR_NONE</a>) 72 00080 iContainer-><a class="code" href="classCallbackTimerObserver.html#a0">TimerBaseElapsed</a>(); 73 00081 } 74 00082 <span class="keyword">private</span>: 75 00083 <a class="code" href="classCallbackTimerObserver.html">CallbackTimerObserver</a> *iContainer; 76 00084 }; 77 00085 78 00086 79 00087 <span class="keyword">template</span><<span class="keyword">class</span> Alloc> 80 <a name="l00088"></a><a class="code" href="classOsclTimer.html">00088</a> <span class="keyword">class </span><a class="code" href="classOsclTimer.html">OsclTimer</a> : <span class="keyword">public</span> <a class="code" href="classCallbackTimerObserver.html">CallbackTimerObserver</a> 81 00089 { 82 00090 <span class="keyword">public</span>: 83 00091 84 <a name="l00092"></a><a class="code" href="classOsclTimer.html#s0">00092</a> <span class="keyword">typedef</span> <a class="code" href="classCallbackTimer.html">CallbackTimer<Alloc></a> <a class="code" href="classCallbackTimer.html">callback_timer_type</a>; 85 00093 86 00100 <a class="code" href="classOsclTimer.html#a0">OsclTimer</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *name, uint32 frequency = 1, int32 priority = <a class="code" href="classOsclActiveObject.html#s5s2">OsclActiveObject::EPriorityNominal</a>); 87 00101 <span class="keyword">virtual</span> <a class="code" href="classOsclTimer.html#a1">~OsclTimer</a>(); 88 00102 89 <a name="l00109"></a><a class="code" href="classOsclTimer.html#a2">00109</a> <span class="keywordtype">void</span> <a class="code" href="classOsclTimer.html#a2">SetObserver</a>(<a class="code" href="classOsclTimerObserver.html">OsclTimerObserver</a> *obs) 90 00110 { 91 00111 iObserver = obs; 92 00112 } 93 00119 <span class="keywordtype">void</span> <a class="code" href="classOsclTimer.html#a3">SetFrequency</a>(uint32 frequency); 94 00120 95 00127 <span class="keywordtype">void</span> <a class="code" href="classOsclTimer.html#a4">SetExactFrequency</a>(uint32 frequency); 96 00128 97 00142 <span class="keywordtype">void</span> <a class="code" href="classOsclTimer.html#a5">Request</a>(int32 timerID, int32 timeoutInfo, int32 cycles, <a class="code" href="classOsclTimerObserver.html">OsclTimerObserver</a> *obs = 0, <span class="keywordtype">bool</span> recurring = 0); 98 00151 <span class="keywordtype">void</span> <a class="code" href="classOsclTimer.html#a6">Cancel</a>(int32 timerID, int32 timeoutInfo = -1); 99 00155 <span class="keywordtype">void</span> <a class="code" href="classOsclTimer.html#a7">Clear</a>(); 100 00156 101 00157 <span class="keyword">private</span>: 102 00158 <span class="comment">//Note: the timer needs to be a new'd object so that</span> 103 00159 <span class="comment">//the CBase construction zeros the memory.</span> 104 00160 callback_timer_type *iTimer; 105 00161 106 00162 <span class="keyword">typedef</span> <span class="keyword">struct </span>_TimerEntry 107 00163 { 108 00164 int32 iCounter ; 109 00165 int32 iTimerID ; 110 00166 int32 iParam ; 111 00167 <a class="code" href="classOsclTimerObserver.html">OsclTimerObserver</a> *iObserver; 112 00168 <span class="keywordtype">bool</span> iRecurring; 113 00169 int32 iOrigCounter; 114 00170 } TimerEntry; 115 00171 116 00172 <span class="keyword">typedef</span> TimerEntry entry_type; 117 00173 <span class="keyword">typedef</span> <a class="code" href="classOscl__Vector.html">Oscl_Vector<entry_type*, Alloc></a> entries_type; 118 00174 <span class="keyword">typedef</span> <span class="keyword">typename</span> entries_type::iterator entries_type_iterator; 119 00175 120 00176 <a class="code" href="classOsclTimerObserver.html">OsclTimerObserver</a> *iObserver; 121 00177 entries_type iEntries; 122 00178 entries_type iEntriesWaitingToAdd; 123 00179 entries_type iEntriesWaitingToCancel; 124 00180 <a class="code" href="classOscl__TAlloc.html">Oscl_TAlloc<entry_type, Alloc></a> iEntryAllocator; 125 00181 126 00182 <span class="keywordtype">bool</span> iInCallback; 127 00183 128 00184 uint32 iCyclePeriod; 129 00185 uint32 iTickCountPeriod; 130 00186 uint32 iExpectedTimeout; 131 00187 132 00188 <span class="keyword">protected</span>: 133 00189 <span class="keywordtype">void</span> <a class="code" href="classOsclTimer.html#b0">TimerBaseElapsed</a>(); 134 <a name="l00190"></a><a class="code" href="classOsclTimer.html#l0">00190</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classCallbackTimer.html">CallbackTimer</a><Alloc>; 135 00191 }; 136 00192 137 00193 <span class="keyword">template</span><<span class="keyword">class</span> Alloc> 138 <a name="l00194"></a><a class="code" href="classOsclTimer.html#a0">00194</a> <a class="code" href="classOsclTimer.html#a0">OsclTimer<Alloc>::OsclTimer</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *name, uint32 frequency, int32 priority) : 139 00195 iObserver(0) 140 00196 , iInCallback(false) 141 00197 , iTickCountPeriod(0) 142 00198 , iExpectedTimeout(0) 143 00199 { 144 00200 <span class="comment">//use the allocator with placement 'new'</span> 145 00201 Alloc alloc; 146 00202 iTimer = <a class="code" href="group__osclmemory.html#a53">OSCL_PLACEMENT_NEW</a>(alloc.ALLOCATE(<span class="keyword">sizeof</span>(<a class="code" href="classCallbackTimer.html">CallbackTimer<Alloc></a>)), <a class="code" href="classCallbackTimer.html">CallbackTimer<Alloc></a>(*<span class="keyword">this</span>, name, priority)); 147 00203 <a class="code" href="classOsclTimer.html#a3">SetFrequency</a>(frequency); 148 00204 } 149 00205 150 00206 <span class="keyword">template</span><<span class="keyword">class</span> Alloc> 151 <a name="l00207"></a><a class="code" href="classOsclTimer.html#a1">00207</a> <a class="code" href="classOsclTimer.html#a1">OsclTimer<Alloc>::~OsclTimer</a>() 152 00208 { 153 00209 <span class="comment">// Make sure we're cancelled</span> 154 00210 <span class="keywordflow">if</span> (iTimer) 155 00211 iTimer-><a class="code" href="classOsclTimerObject.html#a8">Cancel</a>(); 156 00212 <span class="keywordflow">if</span> (iTimer) 157 00213 { 158 00214 iTimer->OSCL_TEMPLATED_DESTRUCTOR_CALL(<a class="code" href="classCallbackTimer.html">callback_timer_type</a>, <a class="code" href="classCallbackTimer.html">CallbackTimer</a>); 159 00215 Alloc alloc; 160 00216 alloc.deallocate(iTimer); 161 00217 } 162 00218 iTimer = <a class="code" href="group__osclbase.html#a81">NULL</a>; 163 00219 164 00220 <span class="keywordflow">for</span> (entries_type_iterator it = iEntries.<a class="code" href="classOscl__Vector.html#a17">begin</a>(); it != iEntries.<a class="code" href="classOscl__Vector.html#a18">end</a>(); it++) 165 00221 { 166 00222 iEntryAllocator.<a class="code" href="classOscl__TAlloc.html#a5">deallocate</a>(*it); 167 00223 } 168 00224 } 169 00225 170 00226 <span class="keyword">template</span><<span class="keyword">class</span> Alloc> 171 <a name="l00227"></a><a class="code" href="classOsclTimer.html#a3">00227</a> <span class="keywordtype">void</span> <a class="code" href="classOsclTimer.html#a3">OsclTimer<Alloc>::SetFrequency</a>(uint32 frequency) 172 00228 { 173 00229 <span class="comment">// timer takes microseconds</span> 174 00230 iCyclePeriod = 1000000 / frequency; 175 00231 <span class="comment">// get tick count period</span> 176 00232 iTickCountPeriod = <a class="code" href="classOsclTickCount.html#d2">OsclTickCount::TickCountPeriod</a>(); 177 00233 } 178 00234 179 00235 <span class="keyword">template</span><<span class="keyword">class</span> Alloc> 180 <a name="l00236"></a><a class="code" href="classOsclTimer.html#a4">00236</a> <span class="keywordtype">void</span> <a class="code" href="classOsclTimer.html#a4">OsclTimer<Alloc>::SetExactFrequency</a>(uint32 frequency) 181 00237 { 182 00238 <span class="comment">// timer takes microseconds</span> 183 00239 iCyclePeriod = frequency; 184 00240 <span class="comment">// get tick count period</span> 185 00241 iTickCountPeriod = <a class="code" href="classOsclTickCount.html#d2">OsclTickCount::TickCountPeriod</a>(); 186 00242 } 187 00243 188 00244 <span class="comment">// Request a timer</span> 189 00245 <span class="keyword">template</span><<span class="keyword">class</span> Alloc> 190 <a name="l00246"></a><a class="code" href="classOsclTimer.html#a5">00246</a> <span class="keywordtype">void</span> <a class="code" href="classOsclTimer.html#a5">OsclTimer<Alloc>::Request</a>(int32 timerID, int32 param, int32 cycles, <a class="code" href="classOsclTimerObserver.html">OsclTimerObserver</a> *obs, <span class="keywordtype">bool</span> recurring) 191 00247 { 192 00248 193 00249 <span class="comment">// add to list of timers</span> 194 00250 entry_type *entry = iEntryAllocator.ALLOCATE(1); 195 00251 entry->iTimerID = timerID; 196 00252 entry->iParam = param; 197 00253 entry->iCounter = cycles; 198 00254 entry->iObserver = obs; 199 00255 entry->iRecurring = recurring; 200 00256 entry->iOrigCounter = entry->iCounter; 201 00257 202 00258 <span class="comment">// if the request is called inside of a callback, then we must add it later</span> 203 00259 <span class="keywordflow">if</span> (iInCallback) 204 00260 { 205 00261 iEntriesWaitingToAdd.<a class="code" href="classOscl__Vector.html#a5">push_back</a>(entry); 206 00262 <span class="keywordflow">return</span>; 207 00263 } 208 00264 209 00265 iEntries.<a class="code" href="classOscl__Vector.html#a5">push_back</a>(entry); 210 00266 211 00267 <span class="keywordflow">if</span> (iTimer) 212 00268 { 213 00269 iTimer-><a class="code" href="classOsclTimerObject.html#a5">RunIfNotReady</a>(iCyclePeriod); 214 00270 } 215 00271 216 00272 <span class="keywordflow">if</span> (iExpectedTimeout == 0) 217 00273 { 218 00274 iExpectedTimeout = (<a class="code" href="classOsclTickCount.html#d0">OsclTickCount::TickCount</a>() * iTickCountPeriod) + iCyclePeriod; 219 00275 } 220 00276 } 221 00277 222 00278 <span class="comment">// Cancel a timer</span> 223 00279 <span class="keyword">template</span><<span class="keyword">class</span> Alloc> 224 <a name="l00280"></a><a class="code" href="classOsclTimer.html#a6">00280</a> <span class="keywordtype">void</span> <a class="code" href="classOsclTimer.html#a6">OsclTimer<Alloc>::Cancel</a>(int32 timerID, int32 param) 225 00281 { 226 00282 227 00283 <span class="keywordflow">if</span> (iInCallback) 228 00284 { 229 00285 <span class="comment">// add to list of timers</span> 230 00286 entry_type *entry = iEntryAllocator.ALLOCATE(1); 231 00287 entry->iTimerID = timerID; 232 00288 entry->iParam = param; 233 00289 234 00290 iEntriesWaitingToCancel.<a class="code" href="classOscl__Vector.html#a5">push_back</a>(entry); 235 00291 <span class="keywordflow">return</span>; 236 00292 } 237 00293 238 00294 <span class="comment">// remove from list of timers</span> 239 00295 <span class="keywordflow">for</span> (entries_type_iterator it = iEntries.<a class="code" href="classOscl__Vector.html#a17">begin</a>(); it != iEntries.<a class="code" href="classOscl__Vector.html#a18">end</a>(); it++) 240 00296 { 241 00297 <span class="keywordflow">if</span> ((*it)->iTimerID == timerID) 242 00298 { 243 00299 <span class="comment">// make sure the param matches unless it is not specified (-1)</span> 244 00300 <span class="keywordflow">if</span> ((*it)->iParam == param || param == -1) 245 00301 { 246 00302 iEntryAllocator.<a class="code" href="classOscl__TAlloc.html#a5">deallocate</a>(*it); 247 00303 iEntries.<a class="code" href="classOscl__Vector.html#a19">erase</a>(it); 248 00304 <span class="keywordflow">return</span>; 249 00305 } 250 00306 } 251 00307 } 252 00308 } 253 00309 254 00310 <span class="comment">// Clear all waiting timers</span> 255 00311 <span class="keyword">template</span><<span class="keyword">class</span> Alloc> 256 <a name="l00312"></a><a class="code" href="classOsclTimer.html#a7">00312</a> <span class="keywordtype">void</span> <a class="code" href="classOsclTimer.html#a7">OsclTimer<Alloc>::Clear</a>() 257 00313 { 258 00314 <span class="keywordflow">for</span> (entries_type_iterator it = iEntries.<a class="code" href="classOscl__Vector.html#a17">begin</a>(); it != iEntries.<a class="code" href="classOscl__Vector.html#a18">end</a>(); it++) 259 00315 { 260 00316 iEntryAllocator.<a class="code" href="classOscl__TAlloc.html#a5">deallocate</a>(*it); 261 00317 } 262 00318 iEntries.<a class="code" href="classOscl__Vector.html#a15">clear</a>(); 263 00319 } 264 00320 265 00321 <span class="keyword">template</span><<span class="keyword">class</span> Alloc> 266 <a name="l00322"></a><a class="code" href="classOsclTimer.html#b0">00322</a> <span class="keywordtype">void</span> <a class="code" href="classOsclTimer.html#b0">OsclTimer<Alloc>::TimerBaseElapsed</a>() 267 00323 { 268 00324 uint8 expiredFound = 0; 269 00325 270 00326 { 271 00327 <span class="comment">// call all whose timers have expired</span> 272 00328 <span class="keywordflow">for</span> (entries_type_iterator it = iEntries.<a class="code" href="classOscl__Vector.html#a17">begin</a>(); it != iEntries.<a class="code" href="classOscl__Vector.html#a18">end</a>(); it++) 273 00329 { 274 00330 entry_type *entry = (*it); 275 00331 <span class="keywordflow">if</span> (--(entry->iCounter) <= 0) 276 00332 { 277 00333 <span class="keywordflow">if</span> (!entry->iRecurring) expiredFound = 1; 278 00334 <span class="keywordflow">if</span> (entry->iRecurring) entry->iCounter = entry->iOrigCounter; 279 00335 280 00336 <span class="comment">// use local observer if it exists, otherwise use global observer</span> 281 00337 <a class="code" href="classOsclTimerObserver.html">OsclTimerObserver</a> *obs = (entry->iObserver ? entry->iObserver : iObserver); 282 00338 <span class="keywordflow">if</span> (obs) 283 00339 { 284 00340 iInCallback = <span class="keyword">true</span>; 285 00341 obs-><a class="code" href="classOsclTimerObserver.html#a0">TimeoutOccurred</a>(entry->iTimerID, entry->iParam); 286 00342 iInCallback = <span class="keyword">false</span>; 287 00343 } 288 00344 } 289 00345 } 290 00346 } 291 00347 292 00348 <span class="comment">// remove from list all whose timers have expired</span> 293 00349 <span class="keywordflow">while</span> (expiredFound) 294 00350 { 295 00351 expiredFound = 0; 296 00352 <span class="keywordflow">for</span> (entries_type_iterator it = iEntries.<a class="code" href="classOscl__Vector.html#a17">begin</a>(); it != iEntries.<a class="code" href="classOscl__Vector.html#a18">end</a>(); it++) 297 00353 { 298 00354 entry_type *entry = (*it); 299 00355 <span class="keywordflow">if</span> (entry->iCounter <= 0) 300 00356 { 301 00357 expiredFound = 1; 302 00358 iEntryAllocator.<a class="code" href="classOscl__TAlloc.html#a5">deallocate</a>(entry); 303 00359 iEntries.<a class="code" href="classOscl__Vector.html#a19">erase</a>(it); 304 00360 <span class="keywordflow">break</span>; 305 00361 } 306 00362 } 307 00363 } 308 00364 309 00365 { 310 00366 <span class="comment">// if any timers were cancelled in the callback, process them now</span> 311 00367 <span class="keywordflow">for</span> (entries_type_iterator it = iEntriesWaitingToCancel.<a class="code" href="classOscl__Vector.html#a17">begin</a>(); it != iEntriesWaitingToCancel.<a class="code" href="classOscl__Vector.html#a18">end</a>(); it++) 312 00368 { 313 00369 entry_type *entry = (*it); 314 00370 <a class="code" href="classOsclTimer.html#a6">Cancel</a>(entry->iTimerID, entry->iParam); 315 00371 iEntryAllocator.<a class="code" href="classOscl__TAlloc.html#a5">deallocate</a>(entry); 316 00372 } 317 00373 iEntriesWaitingToCancel.<a class="code" href="classOscl__Vector.html#a15">clear</a>(); 318 00374 } 319 00375 320 00376 { 321 00377 <span class="comment">// if any timers were requested in the callback, process them now</span> 322 00378 <span class="keywordflow">for</span> (entries_type_iterator it = iEntriesWaitingToAdd.<a class="code" href="classOscl__Vector.html#a17">begin</a>(); it != iEntriesWaitingToAdd.<a class="code" href="classOscl__Vector.html#a18">end</a>(); it++) 323 00379 { 324 00380 entry_type *entry = (*it); 325 00381 <a class="code" href="classOsclTimer.html#a5">Request</a>(entry->iTimerID, entry->iParam, entry->iCounter, entry->iObserver); 326 00382 iEntryAllocator.<a class="code" href="classOscl__TAlloc.html#a5">deallocate</a>(entry); 327 00383 } 328 00384 iEntriesWaitingToAdd.<a class="code" href="classOscl__Vector.html#a15">clear</a>(); 329 00385 } 330 00386 331 00387 <span class="keywordflow">if</span> (!iEntries.<a class="code" href="classOscl__Vector__Base.html#a2">empty</a>()) 332 00388 { 333 00389 <span class="comment">// adjust for the jitter</span> 334 00390 uint32 time = <a class="code" href="classOsclTickCount.html#d0">OsclTickCount::TickCount</a>() * iTickCountPeriod; 335 00391 int32 jitter = time - iExpectedTimeout; 336 00392 int32 waitperiod = iCyclePeriod - jitter; 337 00393 338 00394 <span class="comment">// currently there is some problem on the phone if we send</span> 339 00395 <span class="comment">// in real-time rather than with a slower (growing delay) H.223 mux output</span> 340 00396 <span class="comment">// if jitter is too large in either direction, start over</span> 341 00397 <span class="keywordflow">if</span> ((uint)<a class="code" href="group__osclbase.html#a93">OSCL_ABS</a>(jitter) > iCyclePeriod) 342 00398 { 343 00399 iExpectedTimeout = time; 344 00400 } 345 00401 <span class="keywordflow">else</span> 346 00402 { 347 00403 iExpectedTimeout += iCyclePeriod; 348 00404 } 349 00405 350 00406 waitperiod = <a class="code" href="group__osclbase.html#a92">OSCL_MAX</a>(waitperiod, 0); 351 00407 352 00408 <span class="keywordflow">if</span> (iTimer) 353 00409 { 354 00410 iTimer-><a class="code" href="classOsclTimerObject.html#a5">RunIfNotReady</a>(waitperiod); 355 00411 } 356 00412 } 357 00413 <span class="keywordflow">else</span> 358 00414 { 359 00415 iExpectedTimeout = 0; 360 00416 } 361 00417 } 362 00418 363 00419 364 00420 365 00421 <span class="preprocessor">#endif</span> 366 </pre></div><hr size="1"><img src="pvlogo_small.jpg"><address style="align: right;"><small>OSCL API</small> 367 <address style="align: left;"><small>Posting Version: OPENCORE_20090310 </small> 368 </small></address> 369 </body> 370 </html> 371