|
|
| 428 |
m_running = true; |
428 |
m_running = true; |
| 429 |
m_synchronizer->SetOrigin (m_currentTs); |
429 |
m_synchronizer->SetOrigin (m_currentTs); |
| 430 |
|
430 |
|
| 431 |
for (;;) |
431 |
// Sleep until signalled |
|
|
432 |
uint64_t tsNow; |
| 433 |
uint64_t tsDelay = 1000000000; // wait time of 1 second (in nanoseconds) |
| 434 |
|
| 435 |
while (!m_stop) |
| 432 |
{ |
436 |
{ |
| 433 |
bool done = false; |
437 |
bool process = false; |
| 434 |
|
|
|
| 435 |
{ |
438 |
{ |
| 436 |
CriticalSection cs (m_mutex); |
439 |
CriticalSection cs (m_mutex); |
| 437 |
// |
440 |
|
| 438 |
// In all cases we stop when the event list is empty. If you are doing a |
441 |
if (!m_events->IsEmpty ()) |
| 439 |
// realtime simulation and you want it to extend out for some time, you must |
|
|
| 440 |
// call StopAt. In the realtime case, this will stick a placeholder event out |
| 441 |
// at the end of time. |
| 442 |
// |
| 443 |
if (m_stop || m_events->IsEmpty ()) |
| 444 |
{ |
442 |
{ |
| 445 |
done = true; |
443 |
process = true; |
|
|
444 |
} |
| 445 |
else |
| 446 |
{ |
| 447 |
// Get current timestamp while holding the critical section |
| 448 |
tsNow = m_synchronizer->GetCurrentRealtime (); |
| 446 |
} |
449 |
} |
| 447 |
} |
450 |
} |
|
|
451 |
|
| 452 |
if (!process) |
| 453 |
{ |
| 454 |
// Sleep until signalled |
| 455 |
tsNow = m_synchronizer->Synchronize (tsNow, tsDelay); |
| 448 |
|
456 |
|
| 449 |
if (done) |
457 |
// Re-check event queue |
| 450 |
{ |
458 |
continue; |
| 451 |
break; |
|
|
| 452 |
} |
459 |
} |
| 453 |
|
460 |
|
| 454 |
ProcessOneEvent (); |
461 |
ProcessOneEvent (); |