diff options
author | Fedor Indutny <fedor.indutny@gmail.com> | 2011-10-07 15:17:51 +0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-10-07 01:31:35 -0700 |
commit | 698455384fca6c274c01048b651a3eefe712f5bb (patch) | |
tree | 3067d4f2027e9438627f78b80095a42d1a9d9eb2 /src/node_os.cc | |
parent | b413c77583e4d383a0a7cd4c6c11ff8fdbd312f6 (diff) | |
download | android-node-v8-698455384fca6c274c01048b651a3eefe712f5bb.tar.gz android-node-v8-698455384fca6c274c01048b651a3eefe712f5bb.tar.bz2 android-node-v8-698455384fca6c274c01048b651a3eefe712f5bb.zip |
use uv for memory and loadavg functions
Diffstat (limited to 'src/node_os.cc')
-rw-r--r-- | src/node_os.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/node_os.cc b/src/node_os.cc index 35f5583611..7e3e0896b7 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -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); } |