Browse Source

vm: remove Watchdog dependency on Environment

Remove the Watchdog class' dependency on Environment.
No functional changes, only code cleanup.

PR-URL: https://github.com/nodejs/node/pull/3274
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
process-exit-stdio-flushing
Ido Ben-Yair 9 years ago
committed by Ben Noordhuis
parent
commit
b244f139bf
  1. 2
      src/node_contextify.cc
  2. 9
      src/node_watchdog.cc
  3. 8
      src/node_watchdog.h

2
src/node_contextify.cc

@ -693,7 +693,7 @@ class ContextifyScript : public BaseObject {
Local<Value> result; Local<Value> result;
if (timeout != -1) { if (timeout != -1) {
Watchdog wd(env, timeout); Watchdog wd(env->isolate(), timeout);
result = script->Run(); result = script->Run();
} else { } else {
result = script->Run(); result = script->Run();

9
src/node_watchdog.cc

@ -1,15 +1,14 @@
#include "node_watchdog.h" #include "node_watchdog.h"
#include "env.h"
#include "env-inl.h"
#include "util.h" #include "util.h"
#include "util-inl.h"
namespace node { namespace node {
using v8::V8; using v8::V8;
Watchdog::Watchdog(Environment* env, uint64_t ms) : env_(env), Watchdog::Watchdog(v8::Isolate* isolate, uint64_t ms) : isolate_(isolate),
destroyed_(false) { destroyed_(false) {
int rc; int rc;
loop_ = new uv_loop_t; loop_ = new uv_loop_t;
CHECK(loop_); CHECK(loop_);
@ -84,7 +83,7 @@ void Watchdog::Async(uv_async_t* async) {
void Watchdog::Timer(uv_timer_t* timer) { void Watchdog::Timer(uv_timer_t* timer) {
Watchdog* w = ContainerOf(&Watchdog::timer_, timer); Watchdog* w = ContainerOf(&Watchdog::timer_, timer);
uv_stop(w->loop_); uv_stop(w->loop_);
V8::TerminateExecution(w->env()->isolate()); V8::TerminateExecution(w->isolate());
} }

8
src/node_watchdog.h

@ -4,18 +4,16 @@
#include "v8.h" #include "v8.h"
#include "uv.h" #include "uv.h"
#include "env.h"
namespace node { namespace node {
class Watchdog { class Watchdog {
public: public:
explicit Watchdog(Environment* env, uint64_t ms); explicit Watchdog(v8::Isolate* isolate, uint64_t ms);
~Watchdog(); ~Watchdog();
void Dispose(); void Dispose();
inline Environment* env() const { return env_; } v8::Isolate* isolate() { return isolate_; }
private: private:
void Destroy(); void Destroy();
@ -24,7 +22,7 @@ class Watchdog {
static void Async(uv_async_t* async); static void Async(uv_async_t* async);
static void Timer(uv_timer_t* timer); static void Timer(uv_timer_t* timer);
Environment* env_; v8::Isolate* isolate_;
uv_thread_t thread_; uv_thread_t thread_;
uv_loop_t* loop_; uv_loop_t* loop_;
uv_async_t async_; uv_async_t async_;

Loading…
Cancel
Save