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_);
// 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;
}
#include "spawn_sync.h"
#include "env-inl.h"
#include "string_bytes.h"
+#include "util.h"
#include <string.h>
#include <stdlib.h>
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)
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.