process: remove spinner

Remove the need to call start/stop the uv_idle spinner between
MakeCallbacks. The one place where the tick processor needs to be kicked
is where a user catches uncaughtException. For that we'll now use
setImmediate, which accomplishes the same task.
This commit is contained in:
Trevor Norris committed 2013-05-30 14:51:40 -07:00
1 parent 9a6c0853bc
commit b846842aff
2 files changed
+2 -59

No files matched your search

-42
View File
@@ -140,8 +140,6 @@ bool using_domains = false;
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;
@@ -177,45 +175,6 @@ static uv_async_t emit_debug_enabled_async;
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);
@@ -2378,7 +2337,6 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
// 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);
+2 -17
View File
@@ -285,7 +285,7 @@
}
// if we handled an error, then make sure any ticks get processed
if (caught)
process._needTickCallback();
setImmediate(process._tickCallback);
return caught;
};
};
@@ -316,7 +316,6 @@
};
startup.processNextTick = function() {
var _needTickCallback = process._needTickCallback;
var lastThrew = false;
var nextTickQueue = [];
var needSpinner = true;
@@ -336,7 +335,6 @@
process._nextDomainTick = _nextDomainTick;
process._tickCallback = _tickCallback;
process._tickDomainCallback = _tickDomainCallback;
process._tickFromSpinner = _tickFromSpinner;
function tickDone() {
if (infoBox[length] !== 0) {
@@ -348,23 +346,10 @@
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() {
@@ -396,7 +381,7 @@
if (lastThrew) {
lastThrew = false;
return _needTickCallback();
return;
}
if (inTick) return;