Browse Source

node_file.cc should use NODE_LOOP()

v0.7.4-release
Ryan Dahl 13 years ago
committed by Ben Noordhuis
parent
commit
a0f3eb015a
  1. 6
      src/node_file.cc
  2. 22
      test/simple/test-isolates.js

6
src/node_file.cc

@ -225,7 +225,7 @@ struct fs_req_wrap {
#define ASYNC_CALL(func, callback, ...) \
FSReqWrap* req_wrap = new FSReqWrap(); \
int r = uv_fs_##func(uv_default_loop(), &req_wrap->req_, \
int r = uv_fs_##func(NODE_LOOP(), &req_wrap->req_, \
__VA_ARGS__, After); \
assert(r == 0); \
req_wrap->object_->Set(oncomplete_sym, callback); \
@ -234,9 +234,9 @@ struct fs_req_wrap {
#define SYNC_CALL(func, path, ...) \
fs_req_wrap req_wrap; \
int result = uv_fs_##func(uv_default_loop(), &req_wrap.req, __VA_ARGS__, NULL); \
int result = uv_fs_##func(NODE_LOOP(), &req_wrap.req, __VA_ARGS__, NULL); \
if (result < 0) { \
int code = uv_last_error(uv_default_loop()).code; \
int code = uv_last_error(NODE_LOOP()).code; \
return ThrowException(UVException(code, #func, "", path)); \
}

22
test/simple/test-isolates.js

@ -1,11 +1,27 @@
var fs = require('fs');
console.log("count: %d", process._countIsolate());
if (process.tid === 1) {
var isolate = process._newIsolate(process.argv);
//process._joinIsolate(isolate);
console.error("master");
console.log("count: %d", process._countIsolate());
fs.stat(__dirname, function(err, stat) {
if (err) {
console.error("thread 1 error!");
throw err;
}
console.error('thread 1', stat);
});
console.log("thread 1 count: %d", process._countIsolate());
} else {
console.error("FUCK YEAH!");
console.log("count: %d", process._countIsolate());
console.error("slave");
fs.stat(__dirname, function(err, stat) {
if (err) {
console.error("thread 2 error!");
throw err;
}
console.error('thread 2', stat);
});
console.error("thread 2 count: %d", process._countIsolate());
}

Loading…
Cancel
Save