/** * Used by classes being profiled so that they can avoid unnecessary * code when the data from an Instrument is not being used. * * @return True if an InstrumentProxy has been set and is active. */ public boolean isActive() { return ( m_proxy != null ) && ( m_proxy.isActive() ); }
/** * Increments the Instrument. This method is optimized to be extremely * light weight when an InstrumentManager is not present and there are no * registered CounterInstrumentListeners. */ public void increment() { InstrumentProxy proxy = getInstrumentProxy(); if( proxy != null ) { proxy.increment( 1 ); } }
/** * Sets the current value of the Instrument. This method is optimized * to be extremely light weight when an InstrumentManager is not present * and there are no registered ValueInstrumentListeners. * <p> * Note that in many cases is best to call this method even if the * isActive() method returns false. This is because the InstrumentManager * will remember the last value set and use it if the instrument ever * becomes active. For things like pool sizes which do not change often, * this behavior is critical so that users can begin monitoring the value * and see what it was before they connected. Setting the value is * very light weight, but its calculation may not be. It is up to the * user to weigh the benefits and consequences one way or the other. * * @param value The new value for the Instrument. */ public void setValue( int value ) { InstrumentProxy proxy = getInstrumentProxy(); if( proxy != null ) { proxy.setValue( value ); } } }
/** * Increments the Instrument by a specified count. This method is * optimized to be extremely light weight when an InstrumentManager is not * present and there are no registered CounterInstrumentListeners. * * @param count A positive integer to increment the counter by. * * @throws IllegalArgumentException If the count is not positive. */ public void increment( int count ) { // Check the count if( count <= 0 ) { throw new IllegalArgumentException( "Count must be a positive value." ); } InstrumentProxy proxy = getInstrumentProxy(); if( proxy != null ) { proxy.increment( count ); } } }