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 QueriesThis class is not thread safe. Each query handler instance should only be used in a single thread, preferably in a try-with-resources block.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<PerfDataUtil.PerfCounter,ByRef.CloseableHANDLEByReference>
counterHandleMap
private static org.slf4j.Logger
LOG
private ByRef.CloseableHANDLEByReference
queryHandle
-
Constructor Summary
Constructors Constructor Description PerfCounterQueryHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods 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.
-
-
-
Field Detail
-
LOG
private static final org.slf4j.Logger LOG
-
counterHandleMap
private java.util.Map<PerfDataUtil.PerfCounter,ByRef.CloseableHANDLEByReference> counterHandleMap
-
queryHandle
private ByRef.CloseableHANDLEByReference queryHandle
-
-
Method Detail
-
addCounterToQuery
public boolean addCounterToQuery(PerfDataUtil.PerfCounter counter)
Begin monitoring a Performance Data counter.- Parameters:
counter
- A PerfCounter object.- Returns:
- True if the counter was successfully added to the query.
-
removeCounterFromQuery
public boolean removeCounterFromQuery(PerfDataUtil.PerfCounter counter)
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
public long queryCounter(PerfDataUtil.PerfCounter counter)
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
-
-