[RFC][ReactNative] increase timer resolution

This commit is contained in:
Spencer Ahrens 2015-03-17 22:22:51 -07:00
parent 9086365faf
commit efd56688ba
2 changed files with 7 additions and 1 deletions

View File

@ -90,7 +90,7 @@ var JSTimers = {
JSTimersExecution.timerIDs[freeIndex] = newID;
JSTimersExecution.callbacks[freeIndex] = func;
JSTimersExecution.types[freeIndex] = JSTimersExecution.Type.requestAnimationFrame;
RCTTiming.createTimer(newID, 0, Date.now(), /** recurring */ false);
RCTTiming.createTimer(newID, 1, Date.now(), /** recurring */ false);
return newID;
},

View File

@ -166,6 +166,12 @@
{
RCT_EXPORT();
if (jsDuration == 0 && repeats == NO) {
// For super fast, one-off timers, just enqueue them immediately rather than waiting a frame.
[_bridge enqueueJSCall:@"RCTJSTimers.callTimers" args:@[@[callbackID]]];
return;
}
NSTimeInterval interval = jsDuration / 1000;
NSTimeInterval jsCreationTimeSinceUnixEpoch = jsSchedulingTime / 1000;
NSTimeInterval currentTimeSinceUnixEpoch = [[NSDate date] timeIntervalSince1970];