org.kairosdb.eventbus.Pipeline Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kairosdb Show documentation
Show all versions of kairosdb Show documentation
KairosDB is a fast distributed scalable time series abstraction on top of Cassandra.
package org.kairosdb.eventbus;
import com.google.common.collect.ImmutableSortedSet;
import java.util.Collection;
import java.util.Iterator;
public class Pipeline implements Iterable
{
private volatile ImmutableSortedSet m_pipeline;
private final Object m_lock;
public Pipeline()
{
m_lock = new Object();
m_pipeline = ImmutableSortedSet.naturalOrder().build();
}
@Override
public Iterator iterator()
{
return m_pipeline.iterator();
}
public void addAll(Collection subscribers)
{
synchronized (m_lock)
{
m_pipeline = ImmutableSortedSet.naturalOrder()
.addAll(m_pipeline)
.addAll(subscribers).build();
}
}
public int size()
{
return m_pipeline.size();
}
public boolean isEmpty()
{
return m_pipeline.isEmpty();
}
}