From 79cf3f08d3d586155fee4b63aadbd17334b47c02 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 17 Nov 2004 04:56:58 +0000 Subject: [PATCH] ThreadCpu wrapper --- .../src/net/hyperic/sigar/ThreadCpuTime.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 bindings/java/src/net/hyperic/sigar/ThreadCpuTime.java diff --git a/bindings/java/src/net/hyperic/sigar/ThreadCpuTime.java b/bindings/java/src/net/hyperic/sigar/ThreadCpuTime.java new file mode 100644 index 00000000..8e388d40 --- /dev/null +++ b/bindings/java/src/net/hyperic/sigar/ThreadCpuTime.java @@ -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; + } +}