Class Monitor<K,V extends Comparable<V>>
- java.lang.Object
-
- org.symphonyoss.s2.canon.runtime.SynchronousProducer<V>
-
- org.symphonyoss.s2.canon.runtime.cache.Monitor<K,V>
-
- Type Parameters:
K- The key typeV- 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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(org.symphonyoss.s2.fugue.pipeline.IConsumer<V> listener, org.symphonyoss.s2.fugue.core.trace.ITraceContext trace)Add the given listener and optionally call back immediately with the current value.VgetValue()Monitor<K,V>setValue(V value, org.symphonyoss.s2.fugue.core.trace.ITraceContext trace)Monitor<K,V>setValueIfGreater(V value, org.symphonyoss.s2.fugue.core.trace.ITraceContext trace)-
Methods inherited from class org.symphonyoss.s2.canon.runtime.SynchronousProducer
addListener, notify, produce, removeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.symphonyoss.s2.canon.runtime.IProducer
addListener, removeListener
-
-
-
-
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:
setValueIfGreaterin interfaceIMonitor<K>
-
setValue
public Monitor<K,V> setValue(V value, org.symphonyoss.s2.fugue.core.trace.ITraceContext trace)
-
addListener
public void addListener(org.symphonyoss.s2.fugue.pipeline.IConsumer<V> listener, org.symphonyoss.s2.fugue.core.trace.ITraceContext trace)
Description copied from interface:IMonitorAdd the given listener and optionally call back immediately with the current value.- Specified by:
addListenerin interfaceIMonitor<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.
-
-