mirror of https://github.com/nodejs/node.git
src: use new loop API
uv_loop_new and uv_loop_delete are considered deprecated now.pull/5010/head
parent
269de79fbf
commit
6e1eac744b
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue