Skip to content

Commit

Permalink
Rename the domain module to 'domains'
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Oct 13, 2011
1 parent 4e48456 commit 0b3c28e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 35 deletions.
File renamed without changes.
8 changes: 4 additions & 4 deletions lib/fs.js
Expand Up @@ -40,25 +40,25 @@ function wrapReq(method /* , args */) {
args[i - 1] = arguments[i];
}

// If we're using domains, remove the req from the domain
// If we're using domains, remove the req from the domains
// before making the final callback.
if (process.features.domains) {
assert.ok(l > 0);
var callback = args[l - 1];
args[l - 1] = function() {
// closeReq
require('domain').remove(req);
require('domains').remove(req);
callback.call(this, arguments);
};
}

var req = binding[method].apply(binding, args);
if (process.features.domains) require('domain').add(req);
if (process.features.domains) require('domains').add(req);
return req;
}

function closeReq(req) {
if (process.features.domains) require('domain').remove(req);
if (process.features.domains) require('domains').remove(req);
}


Expand Down
10 changes: 5 additions & 5 deletions lib/net.js
Expand Up @@ -3,23 +3,23 @@ var stream = require('stream');
var timers = require('timers');
var util = require('util');
var assert = require('assert');
var domain = require('domain');
var domains = require('domains');

function noop() {};

// constructor for lazy loading
function createPipe() {
var Pipe = process.binding('pipe_wrap').Pipe;
var pipe = new Pipe();
domain.add(pipe);
domains.add(pipe);
return pipe;
}

// constructor for lazy loading
function createTCP() {
var TCP = process.binding('tcp_wrap').TCP;
var tcp = new TCP();
domain.add(tcp);
domains.add(tcp);
return tcp;
}

Expand All @@ -46,12 +46,12 @@ function isPipeName(s) {

function close(handle) {
handle.close();
domain.remove(handle);
domains.remove(handle);
}


function closeReq(req) {
domain.remove(req);
domains.remove(req);
}


Expand Down
40 changes: 20 additions & 20 deletions lib/timers.js
Expand Up @@ -33,7 +33,7 @@ if (process.env.NODE_DEBUG && /timer/.test(process.env.NODE_DEBUG)) {

function closeTimer(t) {
t.close();
require('domain').remove(t);
require('domains').remove(t);
}


Expand Down Expand Up @@ -68,8 +68,8 @@ function insert(item, msecs) {
// This is a special timer which is owned by Node. It must only be in
// the defaultDomain. When it makes callbacks it iterates through a link list
// of pseudo handles and invokes a callback on each. Each item in that
// list can be associated with a domain.
require('domain').addDefaultDomain(list);
// list can be associated with a domains.
require('domains').addDefaultDomain(list);

list.start(msecs, 0);

Expand All @@ -80,10 +80,10 @@ function insert(item, msecs) {
list.ontimeout = function() {
if (process.features.domains) {
assert(this == list);
assert(list.domain);
assert(list.domain == require('domain').defaultDomain);
assert(require('domain').getCurrent() ==
require('domain').defaultDomain);
assert(list.domains);
assert(list.domains == require('domains').defaultDomain);
assert(require('domains').getCurrent() ==
require('domains').defaultDomain);
}

debug('timeout callback ' + msecs);
Expand All @@ -104,15 +104,15 @@ function insert(item, msecs) {

if (first._onTimeout) {
if (process.features.domains) {
// Enter the domain during the callback. 'first' is a pseudo
// Enter the domains during the callback. 'first' is a pseudo
// handle here - actually a pure javascript object but we treat
// it as its own handle.
process.dispatch(first, "_onTimeout");
assert(this == list);
assert(list.domain);
assert(list.domain == require('domain').defaultDomain);
assert(require('domain').getCurrent() ==
require('domain').defaultDomain);
assert(list.domains);
assert(list.domains == require('domains').defaultDomain);
assert(require('domains').getCurrent() ==
require('domains').defaultDomain);
} else {
first._onTimeout();
}
Expand All @@ -124,10 +124,10 @@ function insert(item, msecs) {
assert(L.isEmpty(list));

if (process.features.domains) {
assert(list.domain);
assert(list.domain == require('domain').defaultDomain);
assert(require('domain').getCurrent() ==
require('domain').defaultDomain,
assert(list.domains);
assert(list.domains == require('domains').defaultDomain);
assert(require('domains').getCurrent() ==
require('domains').defaultDomain,
"not in defaultDomain when we expected to be");
}

Expand All @@ -143,7 +143,7 @@ function insert(item, msecs) {

var unenroll = exports.unenroll = function(item) {
L.remove(item);
require('domain').remove(item);
require('domains').remove(item);

var list = lists[item._idleTimeout];
// if empty then stop the watcher
Expand Down Expand Up @@ -192,7 +192,7 @@ function TimerElement(after) {
this._idleTimeout = after;
this._idlePrev = this;
this._idleNext = this;
require('domain').add(this);
require('domains').add(this);
}


Expand All @@ -202,7 +202,7 @@ exports.setTimeout = function(callback, after) {
if (after <= 0) {
// Use the slow case for after == 0
timer = new Timer();
require('domain').add(timer);
require('domains').add(timer);

timer.ontimeout = callback;

Expand Down Expand Up @@ -256,7 +256,7 @@ exports.clearTimeout = function(timer) {

exports.setInterval = function(callback, repeat) {
var timer = new Timer();
require('domain').add(timer);
require('domains').add(timer);

var args = Array.prototype.slice.call(arguments, 2);
timer.ontimeout = function() {
Expand Down
8 changes: 4 additions & 4 deletions src/node.js
Expand Up @@ -192,8 +192,8 @@
if (l === 0) return;

if (process.features.domains) {
var domain = NativeModule.require('domain');
assert(domain.getCurrent() == domain.defaultDomain);
var domains = NativeModule.require('domains');
assert(domains.getCurrent() == domains.defaultDomain);
}

try {
Expand Down Expand Up @@ -537,7 +537,7 @@
if (obj.domain) {
domain = obj.domain
} else {
domain = NativeModule.require('domain').defaultDomain;
domain = NativeModule.require('domains').defaultDomain;
}

domain.enter();
Expand All @@ -552,7 +552,7 @@

domain.exit();

NativeModule.require('domain').pollNewDomains();
NativeModule.require('domains').pollNewDomains();
}

startup();
Expand Down
4 changes: 2 additions & 2 deletions test/simple/test-domains.js
Expand Up @@ -21,14 +21,14 @@

var common = require('../common');
var assert = require('assert');
var domain = require('domain');
var domains = require('domains');

var timerCalled = false;
var connectCallbackCalled = false;

console.log("default domain");

var d = domain.create({ hello: "world" }, function(a) {
var d = domains.create({ hello: "world" }, function(a) {
console.log("inside the domain");
assert.deepEqual(a, { hello: "world" });

Expand Down

0 comments on commit 0b3c28e

Please sign in to comment.