| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b5dda32 commit c67642a
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,22 +34,20 @@ Watchdog::Watchdog(v8::Isolate* isolate, uint64_t ms, bool* timed_out) | |||
| 34 | 34 | : isolate_(isolate), timed_out_(timed_out) { | |
| 35 | 35 | ||
| 36 | 36 | int rc; | |
| 37 | - loop_ = new uv_loop_t; | ||
| 38 | - CHECK(loop_); | ||
| 39 | - rc = uv_loop_init(loop_); | ||
| 37 | + rc = uv_loop_init(&loop_); | ||
| 40 | 38 | if (rc != 0) { | |
| 41 | 39 | FatalError("node::Watchdog::Watchdog()", | |
| 42 | 40 | "Failed to initialize uv loop."); | |
| 43 | 41 | } | |
| 44 | 42 | ||
| 45 | - rc = uv_async_init(loop_, &async_, [](uv_async_t* signal) { | ||
| 43 | + rc = uv_async_init(&loop_, &async_, [](uv_async_t* signal) { | ||
| 46 | 44 | Watchdog* w = ContainerOf(&Watchdog::async_, signal); | |
| 47 | - uv_stop(w->loop_); | ||
| 45 | + uv_stop(&w->loop_); | ||
| 48 | 46 | }); | |
| 49 | 47 | ||
| 50 | 48 | CHECK_EQ(0, rc); | |
| 51 | 49 | ||
| 52 | - rc = uv_timer_init(loop_, &timer_); | ||
| 50 | + rc = uv_timer_init(&loop_, &timer_); | ||
| 53 | 51 | CHECK_EQ(0, rc); | |
| 54 | 52 | ||
| 55 | 53 | rc = uv_timer_start(&timer_, &Watchdog::Timer, ms, 0); | |
@@ -67,11 +65,9 @@ Watchdog::~Watchdog() { | |||
| 67 | 65 | uv_close(reinterpret_cast<uv_handle_t*>(&async_), nullptr); | |
| 68 | 66 | ||
| 69 | 67 | // UV_RUN_DEFAULT so that libuv has a chance to clean up. | |
| 70 | - uv_run(loop_, UV_RUN_DEFAULT); | ||
| 68 | + uv_run(&loop_, UV_RUN_DEFAULT); | ||
| 71 | 69 | ||
| 72 | - CheckedUvLoopClose(loop_); | ||
| 73 | - delete loop_; | ||
| 74 | - loop_ = nullptr; | ||
| 70 | + CheckedUvLoopClose(&loop_); | ||
| 75 | 71 | } | |
| 76 | 72 | ||
| 77 | 73 | ||
@@ -80,7 +76,7 @@ void Watchdog::Run(void* arg) { | |||
| 80 | 76 | ||
| 81 | 77 | // UV_RUN_DEFAULT the loop will be stopped either by the async or the | |
| 82 | 78 | // timer handle. | |
| 83 | - uv_run(wd->loop_, UV_RUN_DEFAULT); | ||
| 79 | + uv_run(&wd->loop_, UV_RUN_DEFAULT); | ||
| 84 | 80 | ||
| 85 | 81 | // Loop ref count reaches zero when both handles are closed. | |
| 86 | 82 | // Close the timer handle on this side and let ~Watchdog() close async_ | |
@@ -91,7 +87,7 @@ void Watchdog::Timer(uv_timer_t* timer) { | |||
| 91 | 87 | Watchdog* w = ContainerOf(&Watchdog::timer_, timer); | |
| 92 | 88 | *w->timed_out_ = true; | |
| 93 | 89 | w->isolate()->TerminateExecution(); | |
| 94 | - uv_stop(w->loop_); | ||
| 90 | + uv_stop(&w->loop_); | ||
| 95 | 91 | } | |
| 96 | 92 | ||
| 97 | 93 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,7 +49,7 @@ class Watchdog { | |||
| 49 | 49 | ||
| 50 | 50 | v8::Isolate* isolate_; | |
| 51 | 51 | uv_thread_t thread_; | |
| 52 | - uv_loop_t* loop_; | ||
| 52 | + uv_loop_t loop_; | ||
| 53 | 53 | uv_async_t async_; | |
| 54 | 54 | uv_timer_t timer_; | |
| 55 | 55 | bool* timed_out_; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments