| 256 | } |
| 257 | |
| 258 | void IOSTimerThread() |
| 259 | { |
| 260 | SetThreadName("IOS-Timer"); |
| 261 | std::unique_lock _l(sTimerMutex); |
| 262 | while (!sTimerThreadStop) |
| 263 | { |
| 264 | if (sTimerByFireTime.empty()) |
| 265 | { |
| 266 | sTimerCV.wait_for(_l, std::chrono::milliseconds(10000)); |
| 267 | continue; |
| 268 | } |
| 269 | IOSTimerId timerId = *sTimerByFireTime.begin(); |
| 270 | IOSTimer& timer = sTimers[timerId]; |
| 271 | HRTick now = HighResolutionTimer::now().getTick(); |
| 272 | if (now >= timer.nextFire) |
| 273 | { |
| 274 | if(timer.repeat == 0) |
| 275 | IOS_TimerSetNextFireTime(timer, 0); |
| 276 | else |
| 277 | IOS_TimerSetNextFireTime(timer, timer.nextFire + timer.repeat); |
| 278 | IOSMsgQueueId queueId = timer.queueId; |
| 279 | uint32 message = timer.message; |
| 280 | // fire timer |
| 281 | _l.unlock(); |
| 282 | IOSMessage msg; |
| 283 | IOS_SendMessage(queueId, message, 1); |
| 284 | _l.lock(); |
| 285 | continue; |
| 286 | } |
| 287 | else |
| 288 | { |
| 289 | sTimerCV.wait_for(_l, std::chrono::microseconds(HighResolutionTimer::ticksToMicroseconds(timer.nextFire - now))); |
| 290 | } |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | /* devices and IPC */ |
| 295 |
nothing calls this directly
no test coverage detected