Package org.symphonyoss.s2.canon.runtime
Class SynchronousProducer<V>
- java.lang.Object
-
- org.symphonyoss.s2.canon.runtime.SynchronousProducer<V>
-
- Type Parameters:
V- The listener payload
- All Implemented Interfaces:
IProducer<V>,IProducerImpl<V>
- Direct Known Subclasses:
AsynchronousProducer,Monitor
public class SynchronousProducer<V> extends Object implements IProducerImpl<V>
A simple implementation of IProducer which calls listeners in the current thread. If listener implementations block then there may be performance issues so they should not do so, but they need not be thread safe.- Author:
- bruce.skingle
-
-
Constructor Summary
Constructors Constructor Description SynchronousProducer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(org.symphonyoss.s2.fugue.pipeline.IConsumer<V> listener)Add a listener which will be notified for each new object created.protected voidnotify(org.symphonyoss.s2.fugue.pipeline.IConsumer<V> listener, V value, org.symphonyoss.s2.fugue.core.trace.ITraceContext trace)voidproduce(V value, org.symphonyoss.s2.fugue.core.trace.ITraceContext trace)Notify all registered listeners that the given item has been produced.booleanremoveListener(org.symphonyoss.s2.fugue.pipeline.IConsumer<V> listener)Remove the give listener.
-
-
-
Method Detail
-
addListener
public void addListener(org.symphonyoss.s2.fugue.pipeline.IConsumer<V> listener)
Description copied from interface:IProducerAdd a listener which will be notified for each new object created.- Specified by:
addListenerin interfaceIProducer<V>- Parameters:
listener- A listener for new objects.
-
removeListener
public boolean removeListener(org.symphonyoss.s2.fugue.pipeline.IConsumer<V> listener)
Description copied from interface:IProducerRemove the give listener.- Specified by:
removeListenerin interfaceIProducer<V>- Parameters:
listener- A listener for new objects.- Returns:
- true if the listener was removed, false if the given listener was not registered.
-
produce
public void produce(V value, org.symphonyoss.s2.fugue.core.trace.ITraceContext trace)
Description copied from interface:IProducerImplNotify all registered listeners that the given item has been produced.- Specified by:
producein interfaceIProducerImpl<V>- Parameters:
value- An item which has been produced.trace- A trace context.
-
-