Browse Source

implement setInterval()

v0.7.4-release
Ryan 16 years ago
parent
commit
4ea5ab63c1
  1. 3
      Makefile
  2. 21
      node_timer.cc

3
Makefile

@ -1,6 +1,7 @@
EVDIR=$(HOME)/local/libev
V8INC = $(HOME)/src/v8/include
V8LIB = $(HOME)/src/v8/libv8_g.a
#V8LIB = $(HOME)/src/v8/libv8_g.a
V8LIB = $(HOME)/src/v8/libv8.a
CFLAGS = -g -I$(V8INC) -Ideps/oi -DHAVE_GNUTLS=0 -Ideps/ebb
LDFLAGS = -lev -pthread # -lefence

21
node_timer.cc

@ -165,7 +165,26 @@ static Handle<Value> setInterval
( const Arguments& args
)
{
assert(0 && "not implemented");
if (args.Length() < 2)
return Undefined();
HandleScope scope;
Local<Function> callback = Local<Function>::Cast(args[0]);
uint32_t delay = args[1]->Uint32Value();
ev_tstamp after = (double)delay / 1000.0;
if (args.Length() > 2)
assert(0 && "extra params to setInterval not yet implemented.");
int argc = 0;
Handle<Value> argv[] = {};
Timer *timer = new Timer(callback, argc, argv, after, after);
Local<External> timeoutID = timer->CreateTimeoutID();
return scope.Close(timeoutID);
}
void

Loading…
Cancel
Save