Class 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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addListener​(org.symphonyoss.s2.fugue.pipeline.IConsumer<V> listener)
      Add a listener which will be notified for each new object created.
      protected void notify​(org.symphonyoss.s2.fugue.pipeline.IConsumer<V> listener, V value, org.symphonyoss.s2.fugue.core.trace.ITraceContext trace)  
      void produce​(V value, org.symphonyoss.s2.fugue.core.trace.ITraceContext trace)
      Notify all registered listeners that the given item has been produced.
      boolean removeListener​(org.symphonyoss.s2.fugue.pipeline.IConsumer<V> listener)
      Remove the give listener.
    • Constructor Detail

      • SynchronousProducer

        public SynchronousProducer()
    • Method Detail

      • addListener

        public void addListener​(org.symphonyoss.s2.fugue.pipeline.IConsumer<V> listener)
        Description copied from interface: IProducer
        Add a listener which will be notified for each new object created.
        Specified by:
        addListener in interface IProducer<V>
        Parameters:
        listener - A listener for new objects.
      • removeListener

        public boolean removeListener​(org.symphonyoss.s2.fugue.pipeline.IConsumer<V> listener)
        Description copied from interface: IProducer
        Remove the give listener.
        Specified by:
        removeListener in interface IProducer<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: IProducerImpl
        Notify all registered listeners that the given item has been produced.
        Specified by:
        produce in interface IProducerImpl<V>
        Parameters:
        value - An item which has been produced.
        trace - A trace context.
      • notify

        protected void notify​(org.symphonyoss.s2.fugue.pipeline.IConsumer<V> listener,
                              V value,
                              org.symphonyoss.s2.fugue.core.trace.ITraceContext trace)