From 9b67962a447540e062bb25fc1c324f806f9eecd7 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 11 Mar 2010 12:38:42 -0800 Subject: [PATCH] Add timer.again method --- src/node_timer.cc | 13 +++++++++++++ src/node_timer.h | 1 + 2 files changed, 14 insertions(+) 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);