MCPcopy Create free account
hub / github.com/cemu-project/Cemu / IOSTimerThread

Function IOSTimerThread

src/Cafe/IOSU/kernel/iosu_kernel.cpp:258–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

SetThreadNameFunction · 0.85
IOS_TimerSetNextFireTimeFunction · 0.85
IOS_SendMessageFunction · 0.85
getTickMethod · 0.80
unlockMethod · 0.80
lockMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected