fun doFrame(frameTimeNanos: Long) { if (isPaused.get()) { return } val frameTimeMillis = frameTimeNanos / 1000000 var timersToCall: WritableArray? = null synchronized(mTimerGuard) { while (!mTimers.isEmpty() && mTimers.peek().mTargetTime < frameTimeMillis) { val timer: Timer = mTimers.poll() if (timersToCall == null) { timersToCall = Arguments.createArray() } timersToCall.pushInt(timer.mCallbackID) if (timer.mRepeat) { timer.mTargetTime = frameTimeMillis + timer.mInterval mTimers.add(timer) } else { mTimerIdsToTimers.remove(timer.mCallbackID) } } } if (timersToCall != null) { org.graalvm.compiler.debug.Assertions.assertNotNull(mJSTimersModule) .callTimers(timersToCall) } org.graalvm.compiler.debug.Assertions.assertNotNull(mReactChoreographer) .postFrameCallback(ReactChoreographer.CallbackType.TIMERS_EVENTS, this) }
Calls all timers that have expired since the last time this frame callback was called .