2013-09-17から1日間の記事一覧

node.ccでのDomain対応

https://github.com/joyent/node/blob/master/src/node.cc ですね。ここには来たくなかったのですが、実はキレイなコードで読みやすかったw。 Handle<Value> MakeDomainCallback(Environment* env, const Handle<Object> object, const Handle<Function> callback, int argc, Handle<Value> a</value></function></object></value>…

Timer系でのDomain対応

そしてほぼ最後。Timer系関数でのDomainはどうしているのかというと。 // timers.js (v0.10.18) exports.setTimeout = function(callback, after) { // (省略) timer._onTimeout = function() { callback.apply(timer, args); } // (省略) if (process.domai…

EventEmitterでのDomain対応

イベントの伝播の仕組みのほうはEventEmitterのemitそのものに組み込まれています。 // events.js (v0.10.18) EventEmitter.prototype.emit = function(type) { //(省略) if (type === 'error') { if (!this._events.error || (typeof this._events.error …

process.nextTick()でのDomain対応

https://github.com/joyent/node/blob/master/src/node.js Node.jsのスタートアップラウンドのコード、その名もnode.js、ですが、こちらにprocess.nextTick()の定義で、特に遅延させた関数のスタックをループで発火させるところとして_tickDomainCallback()…

Domain#bind()がやってること

var d = require('domain').create(); d.on('error', function(e) { console.log('handled error: ' + e.message); }); d.enter(); //やってることは process.domain = d; fireError.apply(d, []); d.exit(); function fireError() { throw new Error('fire …