missed api _list convention, cpu_infos -> cpu_info_list
This commit is contained in:
1 parent
ca3ecc05f5
commit
ddc6f4c55c
16 files changed
+72
-68
No files matched your search
@@ -7,7 +7,7 @@ public class CpuInfo {
|
||||
Sigar sigar = new Sigar();
|
||||
|
||||
Hyperic.Sigar.CpuInfo[] infos =
|
||||
sigar.CpuInfos();
|
||||
sigar.CpuInfoList();
|
||||
|
||||
System.Console.WriteLine(infos.Length + " total CPUs..");
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ namespace Hyperic.Sigar {
|
||||
return Hyperic.Sigar.Swap.NativeGet(this);
|
||||
}
|
||||
|
||||
public CpuInfo[] CpuInfos() {
|
||||
return Hyperic.Sigar.CpuInfos.NativeGet(this);
|
||||
public CpuInfo[] CpuInfoList() {
|
||||
return Hyperic.Sigar.CpuInfoList.NativeGet(this);
|
||||
}
|
||||
|
||||
public FileSystem[] FileSystemList() {
|
||||
@@ -126,31 +126,32 @@ namespace Hyperic.Sigar {
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct CpuInfos {
|
||||
internal struct CpuInfoList {
|
||||
private readonly uint Number; //sizeof(unsigned long) == 4
|
||||
private readonly uint size;
|
||||
private readonly IntPtr data;
|
||||
|
||||
[DllImport(Sigar.LIBSIGAR)]
|
||||
private static extern int sigar_cpu_infos_get(IntPtr sigar,
|
||||
IntPtr cpu_infos);
|
||||
|
||||
[DllImport(Sigar.LIBSIGAR)]
|
||||
private static extern int sigar_cpu_infos_destroy(IntPtr sigar,
|
||||
private static extern int sigar_cpu_info_list_get(IntPtr sigar,
|
||||
IntPtr cpu_infos);
|
||||
|
||||
[DllImport(Sigar.LIBSIGAR)]
|
||||
private static extern int sigar_cpu_info_list_destroy(IntPtr sigar,
|
||||
IntPtr cpu_infos);
|
||||
|
||||
internal static CpuInfo[] NativeGet(Sigar sigar) {
|
||||
Type type = typeof(CpuInfos);
|
||||
Type type = typeof(CpuInfoList);
|
||||
IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(type));
|
||||
|
||||
int status = sigar_cpu_infos_get(sigar.sigar.Handle, ptr);
|
||||
int status = sigar_cpu_info_list_get(sigar.sigar.Handle, ptr);
|
||||
|
||||
if (status != Sigar.OK) {
|
||||
Marshal.FreeHGlobal(ptr);
|
||||
throw new ApplicationException("cpu_infos_get");
|
||||
throw new ApplicationException("cpu_info_list_get");
|
||||
}
|
||||
|
||||
CpuInfos infosPtr = (CpuInfos)Marshal.PtrToStructure(ptr, type);
|
||||
CpuInfoList infosPtr =
|
||||
(CpuInfoList)Marshal.PtrToStructure(ptr, type);
|
||||
|
||||
CpuInfo[] infos = new CpuInfo[infosPtr.Number];
|
||||
|
||||
@@ -164,7 +165,7 @@ namespace Hyperic.Sigar {
|
||||
eptr = Sigar.incrementIntPtr(eptr, size);
|
||||
}
|
||||
|
||||
sigar_cpu_infos_destroy(sigar.sigar.Handle, ptr);
|
||||
sigar_cpu_info_list_destroy(sigar.sigar.Handle, ptr);
|
||||
|
||||
Marshal.FreeHGlobal(ptr);
|
||||
|
||||
|
||||
@@ -305,12 +305,12 @@ JNIEXPORT jobjectArray SIGAR_JNI(Sigar_getCpuInfoList)
|
||||
{
|
||||
int status;
|
||||
unsigned int i;
|
||||
sigar_cpu_infos_t cpu_infos;
|
||||
sigar_cpu_info_list_t cpu_infos;
|
||||
jobjectArray cpuarray;
|
||||
jclass cls = SIGAR_FIND_CLASS("CpuInfo");
|
||||
dSIGAR(NULL);
|
||||
|
||||
if ((status = sigar_cpu_infos_get(sigar, &cpu_infos)) != SIGAR_OK) {
|
||||
if ((status = sigar_cpu_info_list_get(sigar, &cpu_infos)) != SIGAR_OK) {
|
||||
sigar_throw_error(env, sigar, status);
|
||||
return NULL;
|
||||
}
|
||||
@@ -326,7 +326,7 @@ JNIEXPORT jobjectArray SIGAR_JNI(Sigar_getCpuInfoList)
|
||||
JENV->SetObjectArrayElement(env, cpuarray, i, info_obj);
|
||||
}
|
||||
|
||||
sigar_cpu_infos_destroy(sigar, &cpu_infos);
|
||||
sigar_cpu_info_list_destroy(sigar, &cpu_infos);
|
||||
|
||||
return cpuarray;
|
||||
}
|
||||
|
||||
@@ -136,13 +136,13 @@ public class Sigar implements SigarProxy {
|
||||
return (this.lastCpu = Cpu.fetch(this));
|
||||
}
|
||||
|
||||
private static void pause(int millis) {
|
||||
static void pause(int millis) {
|
||||
try {
|
||||
Thread.sleep(millis);
|
||||
} catch(InterruptedException e) { }
|
||||
}
|
||||
|
||||
private static void pause() {
|
||||
static void pause() {
|
||||
pause(500);
|
||||
}
|
||||
|
||||
|
||||
@@ -201,15 +201,15 @@ file_system_list(sigar)
|
||||
RETVAL
|
||||
|
||||
SV *
|
||||
cpu_infos(sigar)
|
||||
cpu_info_list(sigar)
|
||||
Sigar sigar
|
||||
|
||||
PREINIT:
|
||||
sigar_cpu_infos_t cpu_infos;
|
||||
sigar_cpu_info_list_t cpu_infos;
|
||||
int status;
|
||||
|
||||
CODE:
|
||||
status = sigar_cpu_infos_get(sigar, &cpu_infos);
|
||||
status = sigar_cpu_info_list_get(sigar, &cpu_infos);
|
||||
|
||||
if (status != SIGAR_OK) {
|
||||
SIGAR_CROAK(sigar, "cpu_infos");
|
||||
@@ -220,7 +220,7 @@ cpu_infos(sigar)
|
||||
sizeof(*cpu_infos.data),
|
||||
"Sigar::CpuInfo");
|
||||
|
||||
sigar_cpu_infos_destroy(sigar, &cpu_infos);
|
||||
sigar_cpu_info_list_destroy(sigar, &cpu_infos);
|
||||
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
@@ -5,7 +5,7 @@ use Sigar;
|
||||
|
||||
my $sigar = new Sigar;
|
||||
|
||||
my $infos = $sigar->cpu_infos;
|
||||
my $infos = $sigar->cpu_info_list;
|
||||
|
||||
my $num = scalar @$infos;
|
||||
|
||||
|
||||
Reference in new issue
Block a user