mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
use uv for memory and loadavg functions
This commit is contained in:
1 parent
b413c77583
commit
698455384f
9 files changed
+10
-270
No files matched your search
+10
-5
@@ -117,7 +117,7 @@ static Handle<Value> GetCPUInfo(const Arguments& args) {
|
||||
|
||||
static Handle<Value> GetFreeMemory(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
double amount = Platform::GetFreeMemory();
|
||||
double amount = uv_get_free_memory();
|
||||
|
||||
if (amount < 0) {
|
||||
return Undefined();
|
||||
@@ -128,7 +128,7 @@ static Handle<Value> GetFreeMemory(const Arguments& args) {
|
||||
|
||||
static Handle<Value> GetTotalMemory(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
double amount = Platform::GetTotalMemory();
|
||||
double amount = uv_get_total_memory();
|
||||
|
||||
if (amount < 0) {
|
||||
return Undefined();
|
||||
@@ -150,13 +150,18 @@ static Handle<Value> GetUptime(const Arguments& args) {
|
||||
|
||||
static Handle<Value> GetLoadAvg(const Arguments& args) {
|
||||
HandleScope scope;
|
||||
Local<Array> loads = Array::New(3);
|
||||
int r = Platform::GetLoadAvg(&loads);
|
||||
double loadavg[3];
|
||||
uv_loadavg(loadavg);
|
||||
|
||||
if (r < 0) {
|
||||
if (loadavg[0] < 0) {
|
||||
return Undefined();
|
||||
}
|
||||
|
||||
Local<Array> loads = Array::New(3);
|
||||
loads->Set(0, Number::New(loadavg[0]));
|
||||
loads->Set(1, Number::New(loadavg[1]));
|
||||
loads->Set(2, Number::New(loadavg[2]));
|
||||
|
||||
return scope.Close(loads);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user