MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / ThreadProc

Method ThreadProc

cpp/src/platform/HidController.cpp:205–246  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Handle receiving data -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

203// Handle receiving data
204//-----------------------------------------------------------------------------
205void HidController::ThreadProc
206(
207 Event* _exitEvent
208)
209{
210 uint32 attempts = 0;
211 while( true )
212 {
213 // Init must have been called successfully during Open, so we
214 // don't do it again until the end of the loop
215 if( m_hHidController )
216 {
217 // Enter read loop. Call will only return if
218 // an exit is requested or an error occurs
219 Read();
220
221 // Reset the attempts, so we get a rapid retry for temporary errors
222 attempts = 0;
223 }
224
225 if( attempts < 25 )
226 {
227 // Retry every 5 seconds for the first two minutes...
228 if( Wait::Single( _exitEvent, 5000 ) >= 0 )
229 {
230 // Exit signalled.
231 break;
232 }
233 }
234 else
235 {
236 // ...retry every 30 seconds after that
237 if( Wait::Single( _exitEvent, 30000 ) >= 0 )
238 {
239 // Exit signalled.
240 break;
241 }
242 }
243
244 Init( ++attempts );
245 }
246}
247
248//-----------------------------------------------------------------------------
249// <HidController::Init>

Callers 1

ThreadEntryPointMethod · 0.45

Calls 1

ReadFunction · 0.85

Tested by

no test coverage detected