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:
parent
7be0d06238
commit
49d30c6478
@ -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());
|
||||
|
@ -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_;
|
||||
|
Loading…
Reference in New Issue
Block a user