ThreadCpu wrapper

This commit is contained in:
Doug MacEachern 2004-11-17 04:56:58 +00:00
parent 7eef781321
commit 79cf3f08d3
1 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,33 @@
package net.hyperic.sigar;
public class ThreadCpuTime extends ThreadCpu {
private ThreadCpu diff = null;
private Sigar sigar;
public ThreadCpuTime(Sigar sigar) {
super();
this.sigar = sigar;
}
public void getCurrent() throws SigarException {
this.nativeGet(this.sigar, 0);
}
public ThreadCpu getDiff() throws SigarException {
long startTotal = this.total;
long startUser = this.user;
long startSys = this.sys;
if (this.diff == null) {
this.diff = new ThreadCpu();
}
getCurrent();
this.diff.total = this.total - startTotal;
this.diff.user = this.user - startUser;
this.diff.sys = this.sys - startSys;
return this.diff;
}
}