]> khamidou — GitHub mirrors - electron.git/commitdiff
Force updating timeout when setTimeout is called, fixes #481.
authorCheng Zhao <zcbenz@gmail.com>
Thu, 7 Aug 2014 02:37:00 +0000 (10:37 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 7 Aug 2014 02:37:38 +0000 (10:37 +0800)
atom/common/lib/init.coffee

index 5da02744275bf432aa04fd26204720ada5c4053c..0d5e8e6b4963469fe0b2f0e5ec06e17faa3e3752 100644 (file)
@@ -25,3 +25,10 @@ wrapWithActivateUvLoop = (func) ->
 process.nextTick = wrapWithActivateUvLoop process.nextTick
 global.setImmediate = wrapWithActivateUvLoop timers.setImmediate
 global.clearImmediate = timers.clearImmediate
+
+# setTimeout needs to update the polling timeout of the event loop, when called
+# under Chromium's event loop the node's event loop won't get a chance to update
+# the timeout, so we have to force the node's event loop to recalculate the
+# timeout in browser process.
+if process.type is 'browser'
+  global.setTimeout = wrapWithActivateUvLoop timers.setTimeout