mirror of https://github.com/nodejs/node.git
Add timer.again method
parent
03f2bfe51f
commit
9b67962a44
|
@ -27,6 +27,7 @@ Timer::Initialize (Handle<Object> 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<Value> Timer::Again(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
Timer *timer = ObjectWrap::Unwrap<Timer>(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();
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ class Timer : ObjectWrap {
|
|||
static v8::Handle<v8::Value> New (const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> Start (const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> Stop (const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> Again (const v8::Arguments& args);
|
||||
static v8::Handle<v8::Value> RepeatGetter (v8::Local<v8::String> property, const v8::AccessorInfo& info);
|
||||
static void RepeatSetter (v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info);
|
||||
|
||||
|
|
Loading…
Reference in New Issue