diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-08-01 02:58:10 +0400 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-08-01 02:58:10 +0400 |
commit | 7772f21b60e8b75dfaadd332c01bcae4e919dce9 (patch) | |
tree | e07a2ad4f1724eab89c3f2826ef7fe8cf165625e /lib | |
parent | d3d8f1b972e1fb99916b32647609ad58f6c16fd9 (diff) |
initial pass at lib/child_process_uv.js
Diffstat (limited to 'lib')
-rw-r--r-- | lib/child_process_legacy.js (renamed from lib/child_process.js) | 0 | ||||
-rw-r--r-- | lib/net_uv.js | 22 |
2 files changed, 17 insertions, 5 deletions
diff --git a/lib/child_process.js b/lib/child_process_legacy.js index edcbaa0a73c..edcbaa0a73c 100644 --- a/lib/child_process.js +++ b/lib/child_process_legacy.js diff --git a/lib/net_uv.js b/lib/net_uv.js index aee816fe6ce..a8c339c248b 100644 --- a/lib/net_uv.js +++ b/lib/net_uv.js @@ -3,8 +3,19 @@ var stream = require('stream'); var timers = require('timers'); var util = require('util'); var assert = require('assert'); -var TCP = process.binding('tcp_wrap').TCP; -var Pipe = process.binding('pipe_wrap').Pipe; + +// constructor for lazy loading +function createPipe() { + var Pipe = process.binding('pipe_wrap').Pipe; + return new Pipe(); +} + +// constructor for lazy loading +function createTCP() { + var TCP = process.binding('tcp_wrap').TCP; + return new TCP(); +} + /* Bit flags for socket._flags */ var FLAG_GOT_EOF = 1 << 0; @@ -35,7 +46,7 @@ exports.connect = exports.createConnection = function(port /* [host], [cb] */) { var s; if (isPipeName(port)) { - s = new Socket({handle:new Pipe}); + s = new Socket({ handle: createPipe() }); } else { s = new Socket(); } @@ -411,7 +422,7 @@ Socket.prototype.connect = function(port /* [host], [cb] */) { var pipe = isPipeName(port); if (this.destroyed || !this._handle) { - this._handle = pipe ? new Pipe() : new TCP(); + this._handle = pipe ? createPipe() : createTCP(); initSocketHandle(this); } @@ -544,7 +555,8 @@ function listen(self, address, port, addressType) { if (!self._handle) { // assign handle in listen, and clean up if bind or listen fails - self._handle = (port == -1 && addressType == -1) ? new Pipe : new TCP; + self._handle = + (port == -1 && addressType == -1) ? createPipe() : createTCP(); } self._handle.socket = self; |