Package oshi.util.platform.windows
Class PerfCounterQueryHandler
java.lang.Object
oshi.util.platform.windows.PerfCounterQueryHandler
- All Implemented Interfaces:
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
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Begin monitoring a Performance Data counter.void
close()
long
queryCounter
(PerfDataUtil.PerfCounter counter) Query the raw counter value of a Performance Data counter.void
Stop monitoring all Performance Data counters and release their resourcesboolean
Stop monitoring a Performance Data counter.long
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 interfaceAutoCloseable
-