net.fortytwo.flow
Class SynchronizedSink<T>

java.lang.Object
  extended by net.fortytwo.flow.SynchronizedSink<T>
Type Parameters:
T - the type of data being passed
All Implemented Interfaces:
Sink<T>

public class SynchronizedSink<T>
extends Object
implements Sink<T>

A pipeline which enforces one data item at a time, regardless of the number of threads writing into the sink. It is thread-safe but protects downstream components which may not be thread-safe.

Author:
Joshua Shinavier (http://fortytwo.net)

Constructor Summary
SynchronizedSink(Sink<T> other)
          Constructs a new synchronized sink using an internal mutex
SynchronizedSink(Sink<T> other, Object mutex)
          Constructs a new synchronized sink using a specified mutex
 
Method Summary
 Object getMutex()
           
 void put(T t)
          Passes a data item into the Sink
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SynchronizedSink

public SynchronizedSink(Sink<T> other,
                        Object mutex)
Constructs a new synchronized sink using a specified mutex

Parameters:
other - the downstream sink which is to be protected
mutex - a mutex to use for synchronization

SynchronizedSink

public SynchronizedSink(Sink<T> other)
Constructs a new synchronized sink using an internal mutex

Parameters:
other - the downstream sink which is to be protected
Method Detail

put

public void put(T t)
         throws RippleException
Description copied from interface: Sink
Passes a data item into the Sink

Specified by:
put in interface Sink<T>
Parameters:
t - the data item being passed
Throws:
RippleException - if a data handling error occors

getMutex

public Object getMutex()
Returns:
the mutex which this pipeline uses for synchronization


Copyright © 2007-2014. All Rights Reserved.