| java.lang.Object org.jicarilla.plumbing.SimpleAlternator
SimpleAlternator | public class SimpleAlternator implements Alternator(Code) | | A list-backed
org.jicarilla.plumbing.Alternator which uses the priority as a weight. In
other words, a sink with priority 2*n has twice the chance of being
selected compared to a sink with priority n).
author: Leo Simons version: $Id: SimpleAlternator.java,v 1.2 2004/03/23 13:37:58 lsimons Exp $ |
Field Summary | |
final protected Object | m_mutex synchronization point for
m_sinks . | final protected List | m_sinks the sinks to alternate through. |
m_mutex | final protected Object m_mutex(Code) | | synchronization point for
m_sinks .
|
m_sinks | final protected List m_sinks(Code) | | the sinks to alternate through.
|
SimpleAlternator | public SimpleAlternator()(Code) | | Create a new instance backed by an
ArrayList .
|
addSink | public void addSink(Sink sink)(Code) | | Add a sink with the default priority.
Parameters: sink - the sink to add |
addSink | public void addSink(Sink sink, int priority)(Code) | | Add a sink with the specified priority.
Parameters: sink - the sink to add Parameters: priority - the weight of the sink in determining how oftenit receives a message |
randomSink | protected Sink randomSink()(Code) | | Select a random sink from all referenced sinks.
the selected sink |
|
|