bool no_deprecation = false;
static uv_idle_t tick_spinner;
-static bool need_tick_cb;
-static Persistent<String> tick_callback_sym;
static uv_check_t check_immediate_watcher;
static uv_idle_t idle_immediate_dummy;
Isolate* node_isolate = NULL;
-static void Spin(uv_idle_t* handle, int status) {
- assert(handle == &tick_spinner);
- assert(status == 0);
-
- // Avoid entering a V8 scope.
- if (!need_tick_cb) return;
- need_tick_cb = false;
-
- uv_idle_stop(&tick_spinner);
-
- HandleScope scope(node_isolate);
-
- if (process_tickFromSpinner.IsEmpty()) {
- Local<Value> cb_v = process->Get(String::New("_tickFromSpinner"));
- if (!cb_v->IsFunction()) {
- fprintf(stderr, "process._tickFromSpinner assigned to non-function\n");
- abort();
- }
- Local<Function> cb = cb_v.As<Function>();
- process_tickFromSpinner = Persistent<Function>::New(node_isolate, cb);
- }
-
- TryCatch try_catch;
-
- process_tickFromSpinner->Call(process, 0, NULL);
-
- if (try_catch.HasCaught()) {
- FatalException(try_catch);
- }
-}
-
-
-static Handle<Value> NeedTickCallback(const Arguments& args) {
- need_tick_cb = true;
- uv_idle_start(&tick_spinner, Spin);
- return Undefined(node_isolate);
-}
-
-
static void CheckImmediate(uv_check_t* handle, int status) {
assert(handle == &check_immediate_watcher);
assert(status == 0);
// define various internal methods
NODE_SET_METHOD(process, "_getActiveRequests", GetActiveRequests);
NODE_SET_METHOD(process, "_getActiveHandles", GetActiveHandles);
- NODE_SET_METHOD(process, "_needTickCallback", NeedTickCallback);
NODE_SET_METHOD(process, "reallyExit", Exit);
NODE_SET_METHOD(process, "abort", Abort);
NODE_SET_METHOD(process, "chdir", Chdir);
}
// if we handled an error, then make sure any ticks get processed
if (caught)
- process._needTickCallback();
+ setImmediate(process._tickCallback);
return caught;
};
};
};
startup.processNextTick = function() {
- var _needTickCallback = process._needTickCallback;
var lastThrew = false;
var nextTickQueue = [];
var needSpinner = true;
process._nextDomainTick = _nextDomainTick;
process._tickCallback = _tickCallback;
process._tickDomainCallback = _tickDomainCallback;
- process._tickFromSpinner = _tickFromSpinner;
function tickDone() {
if (infoBox[length] !== 0) {
infoBox[length] = nextTickQueue.length;
}
}
- if (needSpinner) {
- _needTickCallback();
- needSpinner = false;
- }
inTick = false;
infoBox[index] = 0;
}
- function _tickFromSpinner() {
- needSpinner = true;
- // no callbacks to run
- if (infoBox[length] === 0)
- infoBox[index] = 0;
- else
- process._tickCallback();
- }
-
// run callbacks that have no domain
// using domains will cause this to be overridden
function _tickCallback() {
if (lastThrew) {
lastThrew = false;
- return _needTickCallback();
+ return;
}
if (inTick) return;