diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2010-11-11 16:33:21 -0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-11-11 16:34:26 -0800 |
commit | c7b24efd21f5c02a519c429180245ed8c3c320f1 (patch) | |
tree | de5fbc2a544790b83e8a2e5229d4188bd46bc91e /src | |
parent | 4b4d4afa0ad257b54db256940399e73f3f837129 (diff) | |
download | node-new-c7b24efd21f5c02a519c429180245ed8c3c320f1.tar.gz |
Move ev_loop out of javascript
Diffstat (limited to 'src')
-rw-r--r-- | src/node.cc | 38 | ||||
-rw-r--r-- | src/node.js | 9 |
2 files changed, 24 insertions, 23 deletions
diff --git a/src/node.cc b/src/node.cc index d0931a7777..eddd78619d 100644 --- a/src/node.cc +++ b/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(); diff --git a/src/node.js b/src/node.js index f0c8c3042a..04ad4b9e3d 100644 --- a/src/node.js +++ b/src/node.js @@ -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"); - }); |