diff --git a/src/node_timer.cc b/src/node_timer.cc index 1fa470aad3..b1b6d35261 100644 --- a/src/node_timer.cc +++ b/src/node_timer.cc @@ -27,6 +27,7 @@ Timer::Initialize (Handle target) NODE_SET_PROTOTYPE_METHOD(constructor_template, "start", Timer::Start); NODE_SET_PROTOTYPE_METHOD(constructor_template, "stop", Timer::Stop); + NODE_SET_PROTOTYPE_METHOD(constructor_template, "again", Timer::Again); constructor_template->InstanceTemplate()->SetAccessor(repeat_symbol, RepeatGetter, RepeatSetter); @@ -140,3 +141,15 @@ void Timer::Stop () { Unref(); } } + + +Handle Timer::Again(const Arguments& args) { + HandleScope scope; + Timer *timer = ObjectWrap::Unwrap(args.Holder()); + + ev_tstamp repeat = NODE_V8_UNIXTIME(args[0]); + if (repeat > 0) timer->watcher_.repeat = repeat; + ev_timer_again(EV_DEFAULT_UC_ &timer->watcher_); + + return Undefined(); +} diff --git a/src/node_timer.h b/src/node_timer.h index 0472fdb0d6..fdf2a2394f 100644 --- a/src/node_timer.h +++ b/src/node_timer.h @@ -21,6 +21,7 @@ class Timer : ObjectWrap { static v8::Handle New (const v8::Arguments& args); static v8::Handle Start (const v8::Arguments& args); static v8::Handle Stop (const v8::Arguments& args); + static v8::Handle Again (const v8::Arguments& args); static v8::Handle RepeatGetter (v8::Local property, const v8::AccessorInfo& info); static void RepeatSetter (v8::Local property, v8::Local value, const v8::AccessorInfo& info);