Permalink
Browse files

Only Ref in idle watcher when wasn't already active.

  • Loading branch information...
1 parent 7be0d06 commit 49d30c6478df14ca41540ee7c8d8d9279f2a3651 Herbert Vojčík committed with ry Mar 13, 2010
Showing with 9 additions and 5 deletions.
  1. +8 −5 src/node_idle_watcher.cc
  2. +1 −0 src/node_idle_watcher.h
View
@@ -88,14 +88,17 @@ Handle<Value> IdleWatcher::New(const Arguments& args) {
Handle<Value> IdleWatcher::Start(const Arguments& args) {
HandleScope scope;
-
IdleWatcher *idle = ObjectWrap::Unwrap<IdleWatcher>(args.Holder());
+ idle->Start();
+ return Undefined();
+}
- ev_idle_start(EV_DEFAULT_UC_ &idle->watcher_);
-
- idle->Ref();
- return Undefined();
+void IdleWatcher::Start () {
+ if (!watcher_.active) {
+ ev_idle_start(EV_DEFAULT_UC_ &watcher_);
+ Ref();
+ }
}
View
@@ -31,6 +31,7 @@ class IdleWatcher : ObjectWrap {
private:
static void Callback(EV_P_ ev_idle *watcher, int revents);
+ void Start();
void Stop();
ev_idle watcher_;

0 comments on commit 49d30c6

Please sign in to comment.