Class Monitor<K,​V extends Comparable<V>>

  • Type Parameters:
    K - The key type
    V - The value type
    All Implemented Interfaces:
    IMonitor<V>, IProducer<V>, IProducerImpl<V>

    public class Monitor<K,​V extends Comparable<V>>
    extends SynchronousProducer<V>
    implements IMonitor<V>
    An implementation of IMonitor based upon an IProducer which calls listeners in the current thread. Listeners are obliged to return quickly and should not block.
    Author:
    bruce.skingle
    • Constructor Detail

      • Monitor

        public Monitor​(V value)
    • Method Detail

      • setValueIfGreater

        public Monitor<K,​V> setValueIfGreater​(V value,
                                                    org.symphonyoss.s2.fugue.core.trace.ITraceContext trace)
        Specified by:
        setValueIfGreater in interface IMonitor<K>
      • setValue

        public Monitor<K,​V> setValue​(V value,
                                           org.symphonyoss.s2.fugue.core.trace.ITraceContext trace)
        Specified by:
        setValue in interface IMonitor<K>
      • addListener

        public void addListener​(org.symphonyoss.s2.fugue.pipeline.IConsumer<V> listener,
                                org.symphonyoss.s2.fugue.core.trace.ITraceContext trace)
        Description copied from interface: IMonitor
        Add the given listener and optionally call back immediately with the current value.
        Specified by:
        addListener in interface IMonitor<K>
        Parameters:
        listener - A listener which will be called whenever the value of this monitor changes.
        trace - If non-null then call the listener with the current value and the given trace context.