Skip to content
Permalink
Browse files

Implement support for Kernel.free-memory and Kernel.total-memory

  • Loading branch information...
Kaiepi committed Jun 7, 2019
1 parent bf61f59 commit 31671f8f7123e8dd44ec6ab1a16e6b958589b2fc
Showing with 17 additions and 3 deletions.
  1. +17 −3 src/core/Kernel.pm6
@@ -57,7 +57,7 @@ class Kernel does Systemic {
try shell("uname -p", :out, :!err).out.slurp(:close).chomp;
}

submethod BUILD(:$!auth = "unknown" --> Nil) { }
submethod BUILD(:$!auth = 'unknown' --> Nil) { }

method name {
$!name //= do {
@@ -185,9 +185,11 @@ class Kernel does Systemic {
multi method signal(Kernel:D: Signal:D \signal --> Int:D) { signal.value }
multi method signal(Kernel:D: Int:D \signal --> Int:D) { signal }

method cpu-cores() is raw { nqp::cpucores }
method cpu-cores(--> Int) is raw {
nqp::cpucores()
}

method cpu-usage() is raw {
method cpu-usage(--> Int) is raw {
my int @rusage;
nqp::getrusage(@rusage);
nqp::atpos_i(@rusage, nqp::const::RUSAGE_UTIME_SEC) * 1000000
@@ -196,6 +198,18 @@ class Kernel does Systemic {
+ nqp::atpos_i(@rusage, nqp::const::RUSAGE_STIME_MSEC)
}

method free-memory(--> Int) {
nqp::freemem()
}

my $total-mem := nqp::null();
method total-memory(--> Int) {
nqp::ifnull(
$total-mem,
nqp::bind($total-mem,nqp::p6box_i(nqp::totalmem()))
)
}

my $endian := nqp::null;
method endian(--> Endian:D) {
nqp::ifnull(

0 comments on commit 31671f8

Please sign in to comment.
You can’t perform that action at this time.