mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.4 KiB
59 lines
1.4 KiB
var fs = require('fs');
|
|
var http = require('http');
|
|
var isolates = process.binding('isolates');
|
|
|
|
console.log("count: %d", isolates.count());
|
|
|
|
if (process.tid === 1) {
|
|
var isolate = isolates.create(process.argv, {
|
|
debug: function init(d) {
|
|
d.onmessage = function(data) {
|
|
data = JSON.parse(data);
|
|
if (data.event === 'break') {
|
|
d.write(JSON.stringify({
|
|
type: 'request',
|
|
seq: 1,
|
|
command: 'continue'
|
|
}));
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
isolate.onmessage = function() {
|
|
console.error("onmessage");
|
|
};
|
|
isolate.onexit = function() {
|
|
console.error("onexit");
|
|
};
|
|
|
|
console.error("master");
|
|
fs.stat(__dirname, function(err, stat) {
|
|
if (err) throw err;
|
|
console.error('thread 1', stat.mtime);
|
|
});
|
|
|
|
setTimeout(function() {
|
|
fs.stat(__dirname, function(err, stat) {
|
|
if (err) throw err;
|
|
console.error('thread 1', stat.mtime);
|
|
});
|
|
}, 500);
|
|
|
|
console.log("thread 1 count: %d", isolates.count());
|
|
} else {
|
|
console.error("slave");
|
|
fs.stat(__dirname, function(err, stat) {
|
|
if (err) throw err;
|
|
console.error('thread 2', stat.mtime);
|
|
});
|
|
|
|
setTimeout(function() {
|
|
fs.stat(__dirname, function(err, stat) {
|
|
if (err) throw err;
|
|
console.error('thread 2', stat.mtime);
|
|
});
|
|
}, 500);
|
|
|
|
console.error("thread 2 count: %d", isolates.count());
|
|
}
|
|
|