Permalink
Browse files

src: use new loop API

uv_loop_new and uv_loop_delete are considered deprecated now.
  • Loading branch information...
1 parent 269de79 commit 6e1eac744b0c1a84614568ac2b128168ce9138da @saghul saghul committed with indutny Feb 28, 2014
Showing with 15 additions and 5 deletions.
  1. +9 −3 src/node_watchdog.cc
  2. +6 −2 src/spawn_sync.cc
View
@@ -29,10 +29,13 @@ using v8::V8;
Watchdog::Watchdog(uint64_t ms) : destroyed_(false) {
- loop_ = uv_loop_new();
+ int rc;
+ loop_ = new uv_loop_t;
CHECK(loop_);
+ rc = uv_loop_init(loop_);
+ CHECK_EQ(0, rc);
- int rc = uv_async_init(loop_, &async_, &Watchdog::Async);
+ rc = uv_async_init(loop_, &async_, &Watchdog::Async);
CHECK_EQ(0, rc);
rc = uv_timer_init(loop_, &timer_);
@@ -69,7 +72,10 @@ void Watchdog::Destroy() {
// UV_RUN_DEFAULT so that libuv has a chance to clean up.
uv_run(loop_, UV_RUN_DEFAULT);
- uv_loop_delete(loop_);
+ int rc = uv_loop_close(loop_);
+ CHECK_EQ(0, rc);
+ delete loop_;
+ loop_ = NULL;
destroyed_ = true;
}
View
@@ -22,6 +22,7 @@
#include "spawn_sync.h"
#include "env-inl.h"
#include "string_bytes.h"
+#include "util.h"
#include <string.h>
#include <stdlib.h>
@@ -450,9 +451,10 @@ void SyncProcessRunner::TryInitializeAndRunLoop(Local<Value> options) {
assert(lifecycle_ == kUninitialized);
lifecycle_ = kInitialized;
- uv_loop_ = uv_loop_new();
+ uv_loop_ = new uv_loop_t;
if (uv_loop_ == NULL)
return SetError(UV_ENOMEM);
+ CHECK_EQ(uv_loop_init(uv_loop_), 0);
r = ParseOptions(options);
if (r < 0)
@@ -515,7 +517,9 @@ void SyncProcessRunner::CloseHandlesAndDeleteLoop() {
if (r < 0)
abort();
- uv_loop_delete(uv_loop_);
+ CHECK_EQ(uv_loop_close(uv_loop_), 0);
+ delete uv_loop_;
+ uv_loop_ = NULL;
} else {
// If the loop doesn't exist, neither should any pipes or timers.

0 comments on commit 6e1eac7

Please sign in to comment.