diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2014-10-13 15:19:55 +0200 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2014-10-13 23:46:46 +0400 |
commit | d3c317e08ac6a624fde8b242905992eafdd954ac (patch) | |
tree | 1dd2756855ab5b4513503acc660705fa898c5c64 /src/timer_wrap.cc | |
parent | b45d33617b569bf5fa84c9343da9f7d129756968 (diff) | |
download | android-node-v8-d3c317e08ac6a624fde8b242905992eafdd954ac.tar.gz android-node-v8-d3c317e08ac6a624fde8b242905992eafdd954ac.tar.bz2 android-node-v8-d3c317e08ac6a624fde8b242905992eafdd954ac.zip |
src: attach env directly to api functions
Attach the per-context execution environment directly to API functions.
Rationale:
* Gets node one step closer to multi-isolate readiness.
* Avoids multi-context confusion, e.g. when the caller and callee live
in different contexts.
* Avoids expensive calls to pthread_getspecific() on platforms where
V8 does not know how to use the thread-local storage directly.
(Linux, the BSDs.)
PR-URL: https://github.com/node-forward/node/pull/18
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Diffstat (limited to 'src/timer_wrap.cc')
-rw-r--r-- | src/timer_wrap.cc | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/timer_wrap.cc b/src/timer_wrap.cc index f9a2db39fe..0155505532 100644 --- a/src/timer_wrap.cc +++ b/src/timer_wrap.cc @@ -50,24 +50,23 @@ class TimerWrap : public HandleWrap { Handle<Value> unused, Handle<Context> context) { Environment* env = Environment::GetCurrent(context); - Local<FunctionTemplate> constructor = FunctionTemplate::New(env->isolate(), - New); + Local<FunctionTemplate> constructor = env->NewFunctionTemplate(New); constructor->InstanceTemplate()->SetInternalFieldCount(1); constructor->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Timer")); constructor->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "kOnTimeout"), Integer::New(env->isolate(), kOnTimeout)); - NODE_SET_METHOD(constructor, "now", Now); + env->SetTemplateMethod(constructor, "now", Now); - NODE_SET_PROTOTYPE_METHOD(constructor, "close", HandleWrap::Close); - NODE_SET_PROTOTYPE_METHOD(constructor, "ref", HandleWrap::Ref); - NODE_SET_PROTOTYPE_METHOD(constructor, "unref", HandleWrap::Unref); + env->SetProtoMethod(constructor, "close", HandleWrap::Close); + env->SetProtoMethod(constructor, "ref", HandleWrap::Ref); + env->SetProtoMethod(constructor, "unref", HandleWrap::Unref); - NODE_SET_PROTOTYPE_METHOD(constructor, "start", Start); - NODE_SET_PROTOTYPE_METHOD(constructor, "stop", Stop); - NODE_SET_PROTOTYPE_METHOD(constructor, "setRepeat", SetRepeat); - NODE_SET_PROTOTYPE_METHOD(constructor, "getRepeat", GetRepeat); - NODE_SET_PROTOTYPE_METHOD(constructor, "again", Again); + env->SetProtoMethod(constructor, "start", Start); + env->SetProtoMethod(constructor, "stop", Stop); + env->SetProtoMethod(constructor, "setRepeat", SetRepeat); + env->SetProtoMethod(constructor, "getRepeat", GetRepeat); + env->SetProtoMethod(constructor, "again", Again); target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Timer"), constructor->GetFunction()); @@ -79,7 +78,7 @@ class TimerWrap : public HandleWrap { // Therefore we assert that we are not trying to call this as a // normal function. CHECK(args.IsConstructCall()); - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); new TimerWrap(env, args.This()); } @@ -145,7 +144,7 @@ class TimerWrap : public HandleWrap { } static void Now(const FunctionCallbackInfo<Value>& args) { - Environment* env = Environment::GetCurrent(args.GetIsolate()); + Environment* env = Environment::GetCurrent(args); uv_update_time(env->event_loop()); uint64_t now = uv_now(env->event_loop()); if (now <= 0xfffffff) |