From a0f3eb015a9a062746b7dc5d562108d6fb98209a Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sun, 18 Dec 2011 22:49:20 -0800 Subject: [PATCH] node_file.cc should use NODE_LOOP() --- src/node_file.cc | 6 +++--- test/simple/test-isolates.js | 22 +++++++++++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/node_file.cc b/src/node_file.cc index 4913b69..718b055 100644 --- a/src/node_file.cc +++ b/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)); \ } diff --git a/test/simple/test-isolates.js b/test/simple/test-isolates.js index be09ffc..15b643e 100644 --- a/test/simple/test-isolates.js +++ b/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()); } -- 2.7.4