FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add timer.again method · robbles/node@9b67962 · GitHub

Repository navigation

Commit 9b67962

Browse files
committed
Add timer.again method
1 parent 03f2bfe commit 9b67962

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

‎src/node_timer.cc‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Timer::Initialize (Handle<Object> target)
2727

2828
NODE_SET_PROTOTYPE_METHOD(constructor_template, "start", Timer::Start);
2929
NODE_SET_PROTOTYPE_METHOD(constructor_template, "stop", Timer::Stop);
30+
NODE_SET_PROTOTYPE_METHOD(constructor_template, "again", Timer::Again);
3031

3132
constructor_template->InstanceTemplate()->SetAccessor(repeat_symbol,
3233
RepeatGetter, RepeatSetter);
@@ -140,3 +141,15 @@ void Timer::Stop () {
140141
Unref();
141142
}
142143
}
144+
145+
146+
Handle<Value> Timer::Again(const Arguments& args) {
147+
HandleScope scope;
148+
Timer *timer = ObjectWrap::Unwrap<Timer>(args.Holder());
149+
150+
ev_tstamp repeat = NODE_V8_UNIXTIME(args[0]);
151+
if (repeat > 0) timer->watcher_.repeat = repeat;
152+
ev_timer_again(EV_DEFAULT_UC_ &timer->watcher_);
153+
154+
return Undefined();
155+
}

‎src/node_timer.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Timer : ObjectWrap {
2121
static v8::Handle<v8::Value> New (const v8::Arguments& args);
2222
static v8::Handle<v8::Value> Start (const v8::Arguments& args);
2323
static v8::Handle<v8::Value> Stop (const v8::Arguments& args);
24+
static v8::Handle<v8::Value> Again (const v8::Arguments& args);
2425
static v8::Handle<v8::Value> RepeatGetter (v8::Local<v8::String> property, const v8::AccessorInfo& info);
2526
static void RepeatSetter (v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info);
2627

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL