Add node::Loop() and don't inc node_isolate.h in *.cc
authorRyan Dahl <ry@tinyclouds.org>
Thu, 22 Dec 2011 21:40:26 +0000 (13:40 -0800)
committerBen Noordhuis <info@bnoordhuis.nl>
Thu, 29 Dec 2011 00:56:11 +0000 (01:56 +0100)
node::Loop() replaces the NODE_LOOP macro. This avoids hitting
v8::Isolate::GetCurrent() for each loop lookup when HAVE_ISOLATE==0

15 files changed:
src/cares_wrap.cc
src/fs_event_wrap.cc
src/handle_wrap.cc
src/node.cc
src/node.h
src/node_crypto.cc
src/node_file.cc
src/node_zlib.cc
src/pipe_wrap.cc
src/process_wrap.cc
src/stream_wrap.cc
src/tcp_wrap.cc
src/timer_wrap.cc
src/tty_wrap.cc
src/udp_wrap.cc

index b3e4bd5..64e9658 100644 (file)
@@ -22,7 +22,7 @@
 #include <assert.h>
 #include <node.h>
 #include <req_wrap.h>
-#include <node_isolate.h>
+#include <node_vars.h>
 #include <uv.h>
 
 #include <string.h>
@@ -608,7 +608,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
 
   if (status) {
     // Error
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
     argv[0] = Local<Value>::New(Null());
   } else {
     // Success
@@ -711,7 +711,7 @@ static Handle<Value> GetAddrInfo(const Arguments& args) {
   hints.ai_family = fam;
   hints.ai_socktype = SOCK_STREAM;
 
-  int r = uv_getaddrinfo(NODE_LOOP(),
+  int r = uv_getaddrinfo(Loop(),
                          &req_wrap->req_,
                          AfterGetAddrInfo,
                          *hostname,
@@ -720,7 +720,7 @@ static Handle<Value> GetAddrInfo(const Arguments& args) {
   req_wrap->Dispatched();
 
   if (r) {
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
     delete req_wrap;
     return scope.Close(v8::Null());
   } else {
@@ -737,7 +737,7 @@ static void Initialize(Handle<Object> target) {
   assert(r == ARES_SUCCESS);
 
   struct ares_options options;
-  uv_ares_init_options(NODE_LOOP(), &ares_channel, &options, 0);
+  uv_ares_init_options(Loop(), &ares_channel, &options, 0);
   assert(r == 0);
 
   NODE_SET_METHOD(target, "queryA", Query<QueryAWrap>);
index 2e6dee4..1f99e85 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <node.h>
 #include <handle_wrap.h>
-#include <node_isolate.h>
+#include <node_vars.h>
 
 #include <stdlib.h>
 
@@ -110,15 +110,15 @@ Handle<Value> FSEventWrap::Start(const Arguments& args) {
 
   String::Utf8Value path(args[0]->ToString());
 
-  int r = uv_fs_event_init(NODE_LOOP(), &wrap->handle_, *path, OnEvent, 0);
+  int r = uv_fs_event_init(Loop(), &wrap->handle_, *path, OnEvent, 0);
   if (r == 0) {
     // Check for persistent argument
     if (!args[1]->IsTrue()) {
-      uv_unref(NODE_LOOP());
+      uv_unref(Loop());
     }
     wrap->initialized_ = true;
   } else {
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
   }
 
   return scope.Close(Integer::New(r));
@@ -146,7 +146,7 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
   // assumption that a rename implicitly means an attribute change. Not too
   // unreasonable, right? Still, we should revisit this before v1.0.
   if (status) {
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
     eventStr = String::Empty();
   }
   else if (events & UV_RENAME) {
index 2aff643..f661885 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <node.h>
 #include <handle_wrap.h>
-#include <node_isolate.h>
+#include <node_vars.h>
 
 namespace node {
 
@@ -71,7 +71,7 @@ Handle<Value> HandleWrap::Unref(const Arguments& args) {
   }
 
   wrap->unref = true;
-  uv_unref(NODE_LOOP());
+  uv_unref(Loop());
 
   return v8::Undefined();
 }
index 61b4547..548fdc7 100644 (file)
@@ -147,6 +147,15 @@ void StartThread(Isolate* isolate,
                  char** argv);
 
 
+uv_loop_t* Loop() {
+#if defined(HAVE_ISOLATES) && HAVE_ISOLATES
+  return Isolate::GetCurrent()->GetLoop();
+#else
+  return uv_default_loop();
+#endif
+}
+
+
 static void StartGCTimer () {
   if (!uv_is_active((uv_handle_t*) &gc_timer)) {
     uv_timer_start(&gc_timer, node::CheckStatus, 5000, 5000);
@@ -173,7 +182,7 @@ static void Idle(uv_idle_t* watcher, int status) {
 static void Check(uv_check_t* watcher, int status) {
   assert(watcher == &gc_check);
 
-  tick_times[tick_time_head] = uv_now(NODE_LOOP());
+  tick_times[tick_time_head] = uv_now(Loop());
   tick_time_head = (tick_time_head + 1) % RPM_SAMPLES;
 
   StartGCTimer();
@@ -203,7 +212,7 @@ static void Tick(void) {
   need_tick_cb = false;
   if (uv_is_active((uv_handle_t*) &tick_spinner)) {
     uv_idle_stop(&tick_spinner);
-    uv_unref(NODE_LOOP());
+    uv_unref(Loop());
   }
 
   HandleScope scope;
@@ -245,7 +254,7 @@ static Handle<Value> NeedTickCallback(const Arguments& args) {
   // tick_spinner to keep the event loop alive long enough to handle it.
   if (!uv_is_active((uv_handle_t*) &tick_spinner)) {
     uv_idle_start(&tick_spinner, Spin);
-    uv_ref(NODE_LOOP());
+    uv_ref(Loop());
   }
   return Undefined();
 }
@@ -1497,7 +1506,7 @@ static void CheckStatus(uv_timer_t* watcher, int status) {
     }
   }
 
-  double d = uv_now(NODE_LOOP()) - TICK_TIME(3);
+  double d = uv_now(Loop()) - TICK_TIME(3);
 
   //printfb("timer d = %f\n", d);
 
@@ -1526,7 +1535,7 @@ static Handle<Value> Uptime(const Arguments& args) {
 v8::Handle<v8::Value> UVCounters(const v8::Arguments& args) {
   HandleScope scope;
 
-  uv_counters_t* c = &NODE_LOOP()->counters;
+  uv_counters_t* c = &Loop()->counters;
 
   Local<Object> obj = Object::New();
 
index e8c5324..f17c3fc 100644 (file)
@@ -75,8 +75,6 @@
 #define NODE_STRINGIFY_HELPER(n) #n
 #endif
 
-#define NODE_LOOP() (node::Isolate::GetCurrent()->GetLoop())
-
 namespace node {
 
 int Start(int argc, char *argv[]);
@@ -86,6 +84,10 @@ v8::Handle<v8::Object> SetupProcessObject(int argc, char *argv[]);
 void Load(v8::Handle<v8::Object> process);
 void EmitExit(v8::Handle<v8::Object> process);
 
+// Returns the loop for the current isolate. If compiled with
+// --without-isolates then this will always return uv_default_loop();
+uv_loop_t* Loop();
+
 #define NODE_PSYMBOL(s) \
   v8::Persistent<v8::String>::New(v8::String::NewSymbol(s))
 
index 9cb7280..bcd3949 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <node.h>
 #include <node_buffer.h>
-#include <node_isolate.h>
+#include <node_vars.h>
 #include <node_root_certs.h>
 
 #include <string.h>
@@ -4118,7 +4118,7 @@ PBKDF2(const Arguments& args) {
 
   req = new uv_work_t();
   req->data = request;
-  uv_queue_work(NODE_LOOP(), req, EIO_PBKDF2, EIO_PBKDF2After);
+  uv_queue_work(Loop(), req, EIO_PBKDF2, EIO_PBKDF2After);
 
   return Undefined();
 
@@ -4241,7 +4241,7 @@ Handle<Value> RandomBytes(const Arguments& args) {
     Local<Function> callback_v = Local<Function>(Function::Cast(*args[1]));
     req->callback_ = Persistent<Function>::New(callback_v);
 
-    uv_queue_work(NODE_LOOP(),
+    uv_queue_work(Loop(),
                   &req->work_req_,
                   RandomBytesWork<generator>,
                   RandomBytesAfter<generator>);
index e7293fb..f7d2d87 100644 (file)
@@ -22,7 +22,7 @@
 #include "node.h"
 #include "node_file.h"
 #include "node_buffer.h"
-#include <node_isolate.h>
+#include <node_vars.h>
 #ifdef __POSIX__
 # include "node_stat_watcher.h"
 #endif
@@ -226,7 +226,7 @@ struct fs_req_wrap {
 
 #define ASYNC_CALL(func, callback, ...)                           \
   FSReqWrap* req_wrap = new FSReqWrap();                          \
-  int r = uv_fs_##func(NODE_LOOP(), &req_wrap->req_,              \
+  int r = uv_fs_##func(Loop(), &req_wrap->req_,              \
       __VA_ARGS__, After);                                        \
   assert(r == 0);                                                 \
   req_wrap->object_->Set(oncomplete_sym, callback);               \
@@ -235,9 +235,9 @@ struct fs_req_wrap {
 
 #define SYNC_CALL(func, path, ...)                                \
   fs_req_wrap req_wrap;                                           \
-  int result = uv_fs_##func(NODE_LOOP(), &req_wrap.req, __VA_ARGS__, NULL); \
+  int result = uv_fs_##func(Loop(), &req_wrap.req, __VA_ARGS__, NULL); \
   if (result < 0) {                                               \
-    int code = uv_last_error(NODE_LOOP()).code;             \
+    int code = uv_last_error(Loop()).code;             \
     return ThrowException(UVException(code, #func, "", path));    \
   }
 
index eb7d06d..228427b 100644 (file)
@@ -29,7 +29,7 @@
 
 #include <node.h>
 #include <node_buffer.h>
-#include <node_isolate.h>
+#include <node_vars.h>
 #include <req_wrap.h>
 
 #include <node_vars.h>
@@ -134,7 +134,7 @@ template <node_zlib_mode mode> class ZCtx : public ObjectWrap {
     uv_work_t* work_req = new uv_work_t();
     work_req->data = req_wrap;
 
-    uv_queue_work(NODE_LOOP(),
+    uv_queue_work(Loop(),
                   work_req,
                   ZCtx<mode>::Process,
                   ZCtx<mode>::After);
index 483118a..c33de38 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <node.h>
 #include <node_buffer.h>
-#include <node_isolate.h>
+#include <node_vars.h>
 #include <req_wrap.h>
 #include <handle_wrap.h>
 #include <stream_wrap.h>
@@ -124,7 +124,7 @@ Handle<Value> PipeWrap::New(const Arguments& args) {
 
 PipeWrap::PipeWrap(Handle<Object> object, bool ipc)
     : StreamWrap(object, (uv_stream_t*) &handle_) {
-  int r = uv_pipe_init(NODE_LOOP(), &handle_, ipc);
+  int r = uv_pipe_init(Loop(), &handle_, ipc);
   assert(r == 0); // How do we proxy this error up to javascript?
                   // Suggestion: uv_pipe_init() returns void.
   handle_.data = reinterpret_cast<void*>(this);
@@ -142,7 +142,7 @@ Handle<Value> PipeWrap::Bind(const Arguments& args) {
   int r = uv_pipe_bind(&wrap->handle_, *name);
 
   // Error starting the pipe.
-  if (r) SetErrno(uv_last_error(NODE_LOOP()));
+  if (r) SetErrno(uv_last_error(Loop()));
 
   return scope.Close(Integer::New(r));
 }
@@ -173,7 +173,7 @@ Handle<Value> PipeWrap::Listen(const Arguments& args) {
   int r = uv_listen((uv_stream_t*)&wrap->handle_, backlog, OnConnection);
 
   // Error starting the pipe.
-  if (r) SetErrno(uv_last_error(NODE_LOOP()));
+  if (r) SetErrno(uv_last_error(Loop()));
 
   return scope.Close(Integer::New(r));
 }
@@ -226,7 +226,7 @@ void PipeWrap::AfterConnect(uv_connect_t* req, int status) {
   assert(wrap->object_.IsEmpty() == false);
 
   if (status) {
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
   }
 
   Local<Value> argv[3] = {
index 3d988ac..847a763 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <node.h>
 #include <handle_wrap.h>
-#include <node_isolate.h>
+#include <node_vars.h>
 #include <pipe_wrap.h>
 #include <string.h>
 #include <stdlib.h>
@@ -176,7 +176,7 @@ class ProcessWrap : public HandleWrap {
         Get(String::NewSymbol("windowsVerbatimArguments"))->IsTrue();
 #endif
 
-    int r = uv_spawn(NODE_LOOP(), &wrap->process_, options);
+    int r = uv_spawn(Loop(), &wrap->process_, options);
 
     wrap->SetHandle((uv_handle_t*)&wrap->process_);
     assert(wrap->process_.data == wrap);
@@ -196,7 +196,7 @@ class ProcessWrap : public HandleWrap {
       delete [] options.env;
     }
 
-    if (r) SetErrno(uv_last_error(NODE_LOOP()));
+    if (r) SetErrno(uv_last_error(Loop()));
 
     return scope.Close(Integer::New(r));
   }
@@ -210,7 +210,7 @@ class ProcessWrap : public HandleWrap {
 
     int r = uv_process_kill(&wrap->process_, signal);
 
-    if (r) SetErrno(uv_last_error(NODE_LOOP()));
+    if (r) SetErrno(uv_last_error(Loop()));
 
     return scope.Close(Integer::New(r));
   }
index fbe9152..a64b4c3 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <node.h>
 #include <node_buffer.h>
-#include <node_isolate.h>
+#include <node_vars.h>
 #include <handle_wrap.h>
 #include <stream_wrap.h>
 #include <tcp_wrap.h>
@@ -133,7 +133,7 @@ Handle<Value> StreamWrap::ReadStart(const Arguments& args) {
   }
 
   // Error starting the tcp.
-  if (r) SetErrno(uv_last_error(NODE_LOOP()));
+  if (r) SetErrno(uv_last_error(Loop()));
 
   return scope.Close(Integer::New(r));
 }
@@ -147,7 +147,7 @@ Handle<Value> StreamWrap::ReadStop(const Arguments& args) {
   int r = uv_read_stop(wrap->stream_);
 
   // Error starting the tcp.
-  if (r) SetErrno(uv_last_error(NODE_LOOP()));
+  if (r) SetErrno(uv_last_error(Loop()));
 
   return scope.Close(Integer::New(r));
 }
@@ -226,7 +226,7 @@ void StreamWrap::OnReadCommon(uv_stream_t* handle, ssize_t nread,
       slab_used -= buf.len;
     }
 
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
     MakeCallback(wrap->object_, "onread", 0, NULL);
     return;
   }
@@ -339,7 +339,7 @@ Handle<Value> StreamWrap::Write(const Arguments& args) {
   wrap->UpdateWriteQueueSize();
 
   if (r) {
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
     delete req_wrap;
     return scope.Close(v8::Null());
   } else {
@@ -359,7 +359,7 @@ void StreamWrap::AfterWrite(uv_write_t* req, int status) {
   assert(wrap->object_.IsEmpty() == false);
 
   if (status) {
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
   }
 
   wrap->UpdateWriteQueueSize();
@@ -389,7 +389,7 @@ Handle<Value> StreamWrap::Shutdown(const Arguments& args) {
   req_wrap->Dispatched();
 
   if (r) {
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
     delete req_wrap;
     return scope.Close(v8::Null());
   } else {
@@ -409,7 +409,7 @@ void StreamWrap::AfterShutdown(uv_shutdown_t* req, int status) {
   HandleScope scope;
 
   if (status) {
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
   }
 
   Local<Value> argv[3] = {
index 83fdcdd..2871025 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <node.h>
 #include <node_buffer.h>
-#include <node_isolate.h>
+#include <node_vars.h>
 #include <req_wrap.h>
 #include <handle_wrap.h>
 #include <stream_wrap.h>
@@ -155,7 +155,7 @@ Handle<Value> TCPWrap::New(const Arguments& args) {
 
 TCPWrap::TCPWrap(Handle<Object> object)
     : StreamWrap(object, (uv_stream_t*) &handle_) {
-  int r = uv_tcp_init(NODE_LOOP(), &handle_);
+  int r = uv_tcp_init(Loop(), &handle_);
   assert(r == 0); // How do we proxy this error up to javascript?
                   // Suggestion: uv_tcp_init() returns void.
   UpdateWriteQueueSize();
@@ -183,7 +183,7 @@ Handle<Value> TCPWrap::GetSockName(const Arguments& args) {
 
   Local<Object> sockname = Object::New();
   if (r != 0) {
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
   } else {
     family = address.ss_family;
 
@@ -225,7 +225,7 @@ Handle<Value> TCPWrap::GetPeerName(const Arguments& args) {
 
   Local<Object> sockname = Object::New();
   if (r != 0) {
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
   } else {
     family = address.ss_family;
 
@@ -258,7 +258,7 @@ Handle<Value> TCPWrap::SetNoDelay(const Arguments& args) {
 
   int r = uv_tcp_nodelay(&wrap->handle_, 1);
   if (r)
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
 
   return Undefined();
 }
@@ -274,7 +274,7 @@ Handle<Value> TCPWrap::SetKeepAlive(const Arguments& args) {
 
   int r = uv_tcp_keepalive(&wrap->handle_, enable, delay);
   if (r)
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
 
   return Undefined();
 }
@@ -290,7 +290,7 @@ Handle<Value> TCPWrap::SetSimultaneousAccepts(const Arguments& args) {
 
   int r = uv_tcp_simultaneous_accepts(&wrap->handle_, enable ? 1 : 0);
   if (r)
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
 
   return Undefined();
 }
@@ -309,7 +309,7 @@ Handle<Value> TCPWrap::Bind(const Arguments& args) {
   int r = uv_tcp_bind(&wrap->handle_, address);
 
   // Error starting the tcp.
-  if (r) SetErrno(uv_last_error(NODE_LOOP()));
+  if (r) SetErrno(uv_last_error(Loop()));
 
   return scope.Close(Integer::New(r));
 }
@@ -327,7 +327,7 @@ Handle<Value> TCPWrap::Bind6(const Arguments& args) {
   int r = uv_tcp_bind6(&wrap->handle_, address);
 
   // Error starting the tcp.
-  if (r) SetErrno(uv_last_error(NODE_LOOP()));
+  if (r) SetErrno(uv_last_error(Loop()));
 
   return scope.Close(Integer::New(r));
 }
@@ -343,7 +343,7 @@ Handle<Value> TCPWrap::Listen(const Arguments& args) {
   int r = uv_listen((uv_stream_t*)&wrap->handle_, backlog, OnConnection);
 
   // Error starting the tcp.
-  if (r) SetErrno(uv_last_error(NODE_LOOP()));
+  if (r) SetErrno(uv_last_error(Loop()));
 
   return scope.Close(Integer::New(r));
 }
@@ -378,7 +378,7 @@ void TCPWrap::OnConnection(uv_stream_t* handle, int status) {
     // Successful accept. Call the onconnection callback in JavaScript land.
     argv[0] = client_obj;
   } else {
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
     argv[0] = v8::Null();
   }
 
@@ -397,7 +397,7 @@ void TCPWrap::AfterConnect(uv_connect_t* req, int status) {
   assert(wrap->object_.IsEmpty() == false);
 
   if (status) {
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
   }
 
   Local<Value> argv[3] = {
@@ -433,7 +433,7 @@ Handle<Value> TCPWrap::Connect(const Arguments& args) {
   req_wrap->Dispatched();
 
   if (r) {
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
     delete req_wrap;
     return scope.Close(v8::Null());
   } else {
@@ -460,7 +460,7 @@ Handle<Value> TCPWrap::Connect6(const Arguments& args) {
   req_wrap->Dispatched();
 
   if (r) {
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
     delete req_wrap;
     return scope.Close(v8::Null());
   } else {
index 82b7ec9..2b29e5f 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <node.h>
 #include <handle_wrap.h>
-#include <node_isolate.h>
+#include <node_vars.h>
 
 #define UNWRAP \
   assert(!args.Holder().IsEmpty()); \
@@ -92,7 +92,7 @@ class TimerWrap : public HandleWrap {
       : HandleWrap(object, (uv_handle_t*) &handle_) {
     active_ = false;
 
-    int r = uv_timer_init(NODE_LOOP(), &handle_);
+    int r = uv_timer_init(Loop(), &handle_);
     assert(r == 0);
 
     handle_.data = this;
@@ -100,11 +100,11 @@ class TimerWrap : public HandleWrap {
     // uv_timer_init adds a loop reference. (That is, it calls uv_ref.) This
     // is not the behavior we want in Node. Timers should not increase the
     // ref count of the loop except when active.
-    uv_unref(NODE_LOOP());
+    uv_unref(Loop());
   }
 
   ~TimerWrap() {
-    if (!active_) uv_ref(NODE_LOOP());
+    if (!active_) uv_ref(Loop());
   }
 
   void StateChange() {
@@ -114,11 +114,11 @@ class TimerWrap : public HandleWrap {
     if (!was_active && active_) {
       // If our state is changing from inactive to active, we
       // increase the loop's reference count.
-      uv_ref(NODE_LOOP());
+      uv_ref(Loop());
     } else if (was_active && !active_) {
       // If our state is changing from active to inactive, we
       // decrease the loop's reference count.
-      uv_unref(NODE_LOOP());
+      uv_unref(Loop());
     }
   }
 
@@ -133,7 +133,7 @@ class TimerWrap : public HandleWrap {
     int r = uv_timer_start(&wrap->handle_, OnTimeout, timeout, repeat);
 
     // Error starting the timer.
-    if (r) SetErrno(uv_last_error(NODE_LOOP()));
+    if (r) SetErrno(uv_last_error(Loop()));
 
     wrap->StateChange();
 
@@ -147,7 +147,7 @@ class TimerWrap : public HandleWrap {
 
     int r = uv_timer_stop(&wrap->handle_);
 
-    if (r) SetErrno(uv_last_error(NODE_LOOP()));
+    if (r) SetErrno(uv_last_error(Loop()));
 
     wrap->StateChange();
 
@@ -161,7 +161,7 @@ class TimerWrap : public HandleWrap {
 
     int r = uv_timer_again(&wrap->handle_);
 
-    if (r) SetErrno(uv_last_error(NODE_LOOP()));
+    if (r) SetErrno(uv_last_error(Loop()));
 
     wrap->StateChange();
 
@@ -187,7 +187,7 @@ class TimerWrap : public HandleWrap {
 
     int64_t repeat = uv_timer_get_repeat(&wrap->handle_);
 
-    if (repeat < 0) SetErrno(uv_last_error(NODE_LOOP()));
+    if (repeat < 0) SetErrno(uv_last_error(Loop()));
 
     return scope.Close(Integer::New(repeat));
   }
index 1ec8410..3194901 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <node.h>
 #include <node_buffer.h>
-#include <node_isolate.h>
+#include <node_vars.h>
 #include <req_wrap.h>
 #include <handle_wrap.h>
 #include <stream_wrap.h>
@@ -125,7 +125,7 @@ class TTYWrap : StreamWrap {
     int r = uv_tty_get_winsize(&wrap->handle_, &width, &height);
 
     if (r) {
-      SetErrno(uv_last_error(NODE_LOOP()));
+      SetErrno(uv_last_error(Loop()));
       return v8::Undefined();
     }
 
@@ -144,7 +144,7 @@ class TTYWrap : StreamWrap {
     int r = uv_tty_set_mode(&wrap->handle_, args[0]->IsTrue());
 
     if (r) {
-      SetErrno(uv_last_error(NODE_LOOP()));
+      SetErrno(uv_last_error(Loop()));
     }
 
     return scope.Close(Integer::New(r));
@@ -170,7 +170,7 @@ class TTYWrap : StreamWrap {
 
   TTYWrap(Handle<Object> object, int fd, bool readable)
       : StreamWrap(object, (uv_stream_t*)&handle_) {
-    uv_tty_init(NODE_LOOP(), &handle_, fd, readable);
+    uv_tty_init(Loop(), &handle_, fd, readable);
   }
 
   uv_tty_t handle_;
index f0c487e..dce45ad 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <node.h>
 #include <node_buffer.h>
-#include <node_isolate.h>
+#include <node_vars.h>
 
 #include <req_wrap.h>
 #include <handle_wrap.h>
@@ -104,7 +104,7 @@ private:
 
 UDPWrap::UDPWrap(Handle<Object> object): HandleWrap(object,
                                                     (uv_handle_t*)&handle_) {
-  int r = uv_udp_init(NODE_LOOP(), &handle_);
+  int r = uv_udp_init(Loop(), &handle_);
   assert(r == 0); // can't fail anyway
   handle_.data = reinterpret_cast<void*>(this);
 }
@@ -177,7 +177,7 @@ Handle<Value> UDPWrap::DoBind(const Arguments& args, int family) {
   }
 
   if (r)
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
 
   return scope.Close(Integer::New(r));
 }
@@ -234,7 +234,7 @@ Handle<Value> UDPWrap::DoSend(const Arguments& args, int family) {
   req_wrap->Dispatched();
 
   if (r) {
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
     delete req_wrap;
     return Null();
   }
@@ -261,8 +261,8 @@ Handle<Value> UDPWrap::RecvStart(const Arguments& args) {
 
   // UV_EALREADY means that the socket is already bound but that's okay
   int r = uv_udp_recv_start(&wrap->handle_, OnAlloc, OnRecv);
-  if (r && uv_last_error(NODE_LOOP()).code != UV_EALREADY) {
-    SetErrno(uv_last_error(NODE_LOOP()));
+  if (r && uv_last_error(Loop()).code != UV_EALREADY) {
+    SetErrno(uv_last_error(Loop()));
     return False();
   }
 
@@ -298,7 +298,7 @@ Handle<Value> UDPWrap::GetSockName(const Arguments& args) {
     return scope.Close(sockname);
   }
   else {
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
     return Null();
   }
 }
@@ -317,7 +317,7 @@ void UDPWrap::OnSend(uv_udp_send_t* req, int status) {
   assert(wrap->object_.IsEmpty() == false);
 
   if (status) {
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
   }
 
   Local<Value> argv[4] = {
@@ -365,7 +365,7 @@ void UDPWrap::OnRecv(uv_udp_t* handle,
   };
 
   if (nread == -1) {
-    SetErrno(uv_last_error(NODE_LOOP()));
+    SetErrno(uv_last_error(Loop()));
   }
   else {
     Local<Object> rinfo = Object::New();