Package oshi.util.platform.windows
Class PerfCounterQueryHandler
java.lang.Object
oshi.util.platform.windows.PerfCounterQueryHandler
- All Implemented Interfaces:
java.lang.AutoCloseable
@NotThreadSafe public final class PerfCounterQueryHandler extends java.lang.Object implements java.lang.AutoCloseable
Utility to handle Performance Counter Queries
This class is not thread safe. Each query handler instance should only be used in a single thread, preferably in a try-with-resources block.
-
Constructor Summary
Constructors Constructor Description PerfCounterQueryHandler()
-
Method Summary
Modifier and Type Method Description boolean
addCounterToQuery(PerfDataUtil.PerfCounter counter)
Begin monitoring a Performance Data counter.void
close()
long
queryCounter(PerfDataUtil.PerfCounter counter)
Query the raw counter value of a Performance Data counter.void
removeAllCounters()
Stop monitoring all Performance Data counters and release their resourcesboolean
removeCounterFromQuery(PerfDataUtil.PerfCounter counter)
Stop monitoring a Performance Data counter.long
updateQuery()
Update all counters on this query.
-
Constructor Details
-
PerfCounterQueryHandler
public PerfCounterQueryHandler()
-
-
Method Details
-
addCounterToQuery
Begin monitoring a Performance Data counter.- Parameters:
counter
- A PerfCounter object.- Returns:
- True if the counter was successfully added to the query.
-
removeCounterFromQuery
Stop monitoring a Performance Data counter.- Parameters:
counter
- A PerfCounter object- Returns:
- True if the counter was successfully removed.
-
removeAllCounters
public void removeAllCounters()Stop monitoring all Performance Data counters and release their resources -
updateQuery
public long updateQuery()Update all counters on this query.- Returns:
- The timestamp for the update of all the counters, in milliseconds since the epoch, or 0 if the update failed
-
queryCounter
Query the raw counter value of a Performance Data counter. Further mathematical manipulation/conversion is left to the caller.- Parameters:
counter
- The counter to query- Returns:
- The raw value of the counter
-
close
public void close()- Specified by:
close
in interfacejava.lang.AutoCloseable
-