Move ev_loop out of javascript
This commit is contained in:
parent
4b4d4afa0a
commit
c7b24efd21
38
src/node.cc
38
src/node.cc
@ -1030,19 +1030,6 @@ Local<Value> ExecuteString(Local<String> source, Local<Value> filename) {
|
||||
}
|
||||
|
||||
|
||||
static Handle<Value> Loop(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
assert(args.Length() == 0);
|
||||
|
||||
// TODO Probably don't need to start this each time.
|
||||
// Avoids failing on test/simple/test-eio-race3.js though
|
||||
ev_idle_start(EV_DEFAULT_UC_ &eio_poller);
|
||||
|
||||
ev_loop(EV_DEFAULT_UC_ 0);
|
||||
return Undefined();
|
||||
}
|
||||
|
||||
|
||||
static Handle<Value> Chdir(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
|
||||
@ -1666,7 +1653,6 @@ static void Load(int argc, char *argv[]) {
|
||||
|
||||
|
||||
// define various internal methods
|
||||
NODE_SET_METHOD(process, "loop", Loop);
|
||||
NODE_SET_METHOD(process, "compile", Compile);
|
||||
NODE_SET_METHOD(process, "_needTickCallback", NeedTickCallback);
|
||||
NODE_SET_METHOD(process, "reallyExit", Exit);
|
||||
@ -1982,6 +1968,30 @@ int Start(int argc, char *argv[]) {
|
||||
// so your next reading stop should be node::Load()!
|
||||
node::Load(argc, argv);
|
||||
|
||||
// TODO Probably don't need to start this each time.
|
||||
// Avoids failing on test/simple/test-eio-race3.js though
|
||||
ev_idle_start(EV_DEFAULT_UC_ &eio_poller);
|
||||
|
||||
// All our arguments are loaded. We've evaluated all of the scripts. We
|
||||
// might even have created TCP servers. Now we enter the main eventloop. If
|
||||
// there are no watchers on the loop (except for the ones that were
|
||||
// ev_unref'd) then this function exits. As long as there are active
|
||||
// watchers, it blocks.
|
||||
ev_loop(EV_DEFAULT_UC_ 0);
|
||||
|
||||
|
||||
// process.emit('exit')
|
||||
Local<Value> emit_v = process->Get(String::New("emit"));
|
||||
assert(emit_v->IsFunction());
|
||||
Local<Function> emit = Local<Function>::Cast(emit_v);
|
||||
Local<Value> args[] = { String::New("exit") };
|
||||
TryCatch try_catch;
|
||||
emit->Call(process, 1, args);
|
||||
if (try_catch.HasCaught()) {
|
||||
FatalException(try_catch);
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
// Clean up.
|
||||
context.Dispose();
|
||||
|
@ -608,13 +608,4 @@ if (process.argv[1]) {
|
||||
module.requireNative('repl').start();
|
||||
}
|
||||
|
||||
// All our arguments are loaded. We've evaluated all of the scripts. We
|
||||
// might even have created TCP servers. Now we enter the main eventloop. If
|
||||
// there are no watchers on the loop (except for the ones that were
|
||||
// ev_unref'd) then this function exits. As long as there are active
|
||||
// watchers, it blocks.
|
||||
process.loop();
|
||||
|
||||
process.emit("exit");
|
||||
|
||||
});
|
||||
|
@ -11,4 +11,3 @@ ReferenceError: foo is not defined
|
||||
at Module.load (node.js:*)
|
||||
at Array.<anonymous> (node.js:*)
|
||||
at EventEmitter._tickCallback (node.js:*)
|
||||
at node.js:*
|
||||
|
Loading…
x
Reference in New Issue
Block a user