|
|
|
@ -81,6 +81,7 @@ public final class ConcurrentBag<T extends BagEntry>
|
|
|
|
|
private final Synchronizer synchronizer;
|
|
|
|
|
private final AtomicLong sequence;
|
|
|
|
|
private final IBagStateListener listener;
|
|
|
|
|
private volatile boolean closed;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Construct a ConcurrentBag with the specified listener.
|
|
|
|
@ -179,6 +180,10 @@ public final class ConcurrentBag<T extends BagEntry>
|
|
|
|
|
*/
|
|
|
|
|
public void add(final T bagEntry)
|
|
|
|
|
{
|
|
|
|
|
if (closed) {
|
|
|
|
|
throw new IllegalStateException("ConcurrentBag has been closed");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sharedList.add(bagEntry);
|
|
|
|
|
synchronizer.releaseShared(sequence.incrementAndGet());
|
|
|
|
|
}
|
|
|
|
@ -203,6 +208,14 @@ public final class ConcurrentBag<T extends BagEntry>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Close the bag to further adds.
|
|
|
|
|
*/
|
|
|
|
|
public void close()
|
|
|
|
|
{
|
|
|
|
|
closed = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This method provides a "snaphot" in time of the BagEntry
|
|
|
|
|
* items in the bag in the specified state. It does not "lock"
|
|
|
|
|