Permalink
Browse files

Prefer setImmediate over nextTick if available

  • Loading branch information...
1 parent 2340138 commit f53e2d44898fe0e1aac4ba0cc2aaa9126c1e70cf @andris9 committed Jan 28, 2014
Showing with 19 additions and 4 deletions.
  1. +13 −2 lib/client.js
  2. +5 −1 lib/pool.js
  3. +1 −1 package.json
View
@@ -12,7 +12,13 @@ var Stream = require("stream").Stream,
// expose to the world
module.exports = function(port, host, options){
var connection = new SMTPClient(port, host, options);
- process.nextTick(connection.connect.bind(connection));
+
+ if(typeof setImmediate == "function"){
+ setImmediate(connection.connect.bind(connection));
+ }else{
+ process.nextTick(connection.connect.bind(connection));
+ }
+
return connection;
};
@@ -1022,7 +1028,12 @@ SMTPClient.prototype._actionStream = function(str){
// Waiting for new connections
this._currentAction = this._actionIdle;
- process.nextTick(this.emit.bind(this, "idle"));
+
+ if(typeof setImmediate == "function"){
+ setImmediate(this.emit.bind(this, "idle"));
+ }else{
+ process.nextTick(this.emit.bind(this, "idle"));
+ }
};
/**
View
@@ -140,7 +140,11 @@ SMTPConnectionPool.prototype.close = function(callback){
}
if(callback){
- process.nextTick(callback);
+ if(typeof setImmediate == "function"){
+ setImmediate(callback);
+ }else{
+ process.nextTick(callback);
+ }
}
};
View
@@ -1,7 +1,7 @@
{
"name": "simplesmtp",
"description": "Simple SMTP server module to create custom SMTP servers",
- "version": "0.3.18-rfc1870",
+ "version": "0.3.19",
"author" : "Andris Reinman",
"maintainers":[
{

0 comments on commit f53e2d4

Please sign in to comment.