mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
Add process.now
Faster way to find out current time.
This commit is contained in:
1 parent
462a8f8652
commit
4635ed7fde
1 file changed
+11
+11
@@ -1,6 +1,8 @@
|
||||
// Copyright 2009 Ryan Dahl <ry@tinyclouds.org>
|
||||
#include <node.h>
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -533,6 +535,13 @@ static Handle<Value> SetUid(const Arguments& args) {
|
||||
return Undefined();
|
||||
}
|
||||
|
||||
Handle<Value>
|
||||
NowGetter (Local<String> property, const AccessorInfo& info)
|
||||
{
|
||||
HandleScope scope;
|
||||
return scope.Close(Integer::New(ev_now(EV_DEFAULT_UC)));
|
||||
}
|
||||
|
||||
|
||||
v8::Handle<v8::Value> Exit(const v8::Arguments& args) {
|
||||
HandleScope scope;
|
||||
@@ -1003,6 +1012,8 @@ static void Load(int argc, char *argv[]) {
|
||||
Local<FunctionTemplate> process_template = FunctionTemplate::New();
|
||||
node::EventEmitter::Initialize(process_template);
|
||||
|
||||
process_template->InstanceTemplate()->SetAccessor(String::NewSymbol("now"), NowGetter, NULL);
|
||||
|
||||
process = Persistent<Object>::New(process_template->GetFunction()->NewInstance());
|
||||
|
||||
// Add a reference to the global object
|
||||
|
||||
Reference in new issue
Block a user