0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

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

This commit is contained in:
Herbert Vojčík 2010-03-13 15:35:09 -07:00 committed by Ryan Dahl
parent 7be0d06238
commit 49d30c6478
2 changed files with 10 additions and 6 deletions

View File

@ -88,17 +88,20 @@ Handle<Value> IdleWatcher::New(const Arguments& args) {
Handle<Value> IdleWatcher::Start(const Arguments& args) {
HandleScope scope;
IdleWatcher *idle = ObjectWrap::Unwrap<IdleWatcher>(args.Holder());
ev_idle_start(EV_DEFAULT_UC_ &idle->watcher_);
idle->Ref();
idle->Start();
return Undefined();
}
void IdleWatcher::Start () {
if (!watcher_.active) {
ev_idle_start(EV_DEFAULT_UC_ &watcher_);
Ref();
}
}
Handle<Value> IdleWatcher::Stop(const Arguments& args) {
HandleScope scope;
IdleWatcher *idle = ObjectWrap::Unwrap<IdleWatcher>(args.Holder());

View File

@ -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_;