Also use uv loop fixes in browser process.
authorCheng Zhao <zcbenz@gmail.com>
Mon, 13 Jan 2014 05:57:08 +0000 (13:57 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 13 Jan 2014 05:57:08 +0000 (13:57 +0800)
atom.gyp
browser/lib/init.coffee
common/lib/init.coffee [new file with mode: 0644]
renderer/lib/init.coffee

index f9b4a011f3d24424651bafcf7321b121f565c9c4..288785c13d3132af75c180baa3c95c9554a6c4b0 100644 (file)
--- a/atom.gyp
+++ b/atom.gyp
@@ -30,6 +30,7 @@
       'common/api/lib/id-weak-map.coffee',
       'common/api/lib/screen.coffee',
       'common/api/lib/shell.coffee',
+      'common/lib/init.coffee',
       'renderer/lib/init.coffee',
       'renderer/api/lib/ipc.coffee',
       'renderer/api/lib/remote.coffee',
index d16450f701f47bdf56e5dd66065b5e933a813594..950d4671ac56d32fb281f574a2a8fe187d938e7f 100644 (file)
@@ -1,4 +1,4 @@
-fs = require 'fs'
+fs   = require 'fs'
 path = require 'path'
 
 # Expose information of current process.
@@ -14,12 +14,12 @@ process.argv.splice 1, 1
 globalPaths = require('module').globalPaths
 globalPaths.push path.join process.resourcesPath, 'browser', 'api', 'lib'
 
-# And also common/api/lib
-globalPaths.push path.join process.resourcesPath, 'common', 'api', 'lib'
-
 # Do loading in next tick since we still need some initialize work before
 # native bindings can work.
 setImmediate ->
+  # Import common settings.
+  require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init.js')
+
   if process.platform is 'win32'
     # Redirect node's console to use our own implementations, since node can not
     # handle console output when running as GUI program.
diff --git a/common/lib/init.coffee b/common/lib/init.coffee
new file mode 100644 (file)
index 0000000..48c1b29
--- /dev/null
@@ -0,0 +1,28 @@
+path   = require 'path'
+timers = require 'timers'
+Module = require 'module'
+
+# Add common/api/lib to module search paths.
+globalPaths = Module.globalPaths
+globalPaths.push path.join(process.resourcesPath, 'common', 'api', 'lib')
+
+# setImmediate and process.nextTick makes use of uv_check and uv_prepare to
+# run the callbacks, however since we only run uv loop on requests, the
+# callbacks wouldn't be called until something else activated the uv loop,
+# which would delay the callbacks for arbitrary long time. So we should
+# initiatively activate the uv loop once setImmediate and process.nextTick is
+# called.
+wrapWithActivateUvLoop = (func) ->
+  ->
+    process.activateUvLoop()
+    func.apply this, arguments
+process.nextTick = wrapWithActivateUvLoop process.nextTick
+global.setImmediate = wrapWithActivateUvLoop timers.setImmediate
+global.clearImmediate = timers.clearImmediate
+
+# The child_process module also needs to activate the uv loop to make the ipc
+# channel setup.
+# TODO(zcbenz): Find out why this is needed.
+childProcess = require 'child_process'
+childProcess.spawn = wrapWithActivateUvLoop childProcess.spawn
+childProcess.fork = wrapWithActivateUvLoop childProcess.fork
index 84fb257c19b9c8554b9de28b43db65032dc37878..230529d39baa49b3cdc997376459e24e1dfeef9a 100644 (file)
@@ -1,5 +1,4 @@
 path   = require 'path'
-timers = require 'timers'
 Module = require 'module'
 
 # Expose information of current process.
@@ -14,36 +13,16 @@ process.argv.splice 1, 1
 # of Atom's built-in libraries.
 globalPaths = Module.globalPaths
 globalPaths.push path.join(process.resourcesPath, 'renderer', 'api', 'lib')
-# And also common/api/lib.
-globalPaths.push path.join(process.resourcesPath, 'common', 'api', 'lib')
 # And also app.
 globalPaths.push path.join(process.resourcesPath, 'app')
 
+# Import common settings.
+require path.resolve(__dirname, '..', '..', 'common', 'lib', 'init.js')
+
 # Expose global variables.
 global.require = require
 global.module = module
 
-# setImmediate and process.nextTick makes use of uv_check and uv_prepare to
-# run the callbacks, however since we only run uv loop on requests, the
-# callbacks wouldn't be called until something else activated the uv loop,
-# which would delay the callbacks for arbitrary long time. So we should
-# initiatively activate the uv loop once setImmediate and process.nextTick is
-# called.
-wrapWithActivateUvLoop = (func) ->
-  ->
-    process.activateUvLoop()
-    func.apply this, arguments
-process.nextTick = wrapWithActivateUvLoop process.nextTick
-global.setImmediate = wrapWithActivateUvLoop timers.setImmediate
-global.clearImmediate = timers.clearImmediate
-
-# The child_process module also needs to activate the uv loop to make the ipc
-# channel setup.
-# TODO(zcbenz): Find out why this is needed.
-childProcess = require 'child_process'
-childProcess.spawn = wrapWithActivateUvLoop childProcess.spawn
-childProcess.fork = wrapWithActivateUvLoop childProcess.fork
-
 # Set the __filename to the path of html file if it's file:// protocol.
 if window.location.protocol is 'file:'
   global.__filename =