0

假设我有以下代码:

foo();

function foo() {
   func1("bla", function() {
                console.log("done!");
               });
}

function func1(value,callback) {
       process.nextTick(callback);
}

上面的函数会完全异步吗?或者我应该使用这个 foo 函数吗?:

function foo() {
    process.nextTick(function() { 
                          func1("bla", function() {
                          console.log("done!");
                     });
}

实际上我的问题是父进程是否阻止子进程成为 Async ?

4

1 回答 1

0

The first option is going to be "async" in the sense that node might do other things before calling the callback method.

There is no need to call the second method. As soon as your foo function finishes and any parent callers of foo finish node will start doing other work, which eventually will be the work registered by nextTick.

于 2013-07-31T09:59:40.900 回答