public interface BarrierGroup
A group has a number of barriers, N, and a number of waiters, W. At any time, 0 <= W < N or 0 == W == N.
One or more listeners can be registered with the group.
Whenever N is positive and becomes equal to W, W will
be reset to 0 and all the listeners will be notified.
If removeBarriers(long) reduces N to 0, the instance will
become invalid. This allows implementations to remove barrier groups that are
no longer in use.
This interface tracks the identity of waiting barriers through
BarrierIdentity. Doing so allows communication with the
Barrier API to be asynchronous.
Barrier| Modifier and Type | Interface and Description |
|---|---|
static interface |
BarrierGroup.Listener
Callback used to notify listeners.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addBarrier()
Increase the number of barriers in the group.
|
void |
addListener(BarrierGroup.Listener listener)
Add a listener.
|
void |
addWaiter(BarrierIdentity barrierIdentity)
Add a waiter.
|
void |
cancelAll()
Cancels all waiters and removes all barriers.
|
void |
cancelWaiter(BarrierIdentity barrierIdentity)
Cancel a waiter.
|
String |
getName()
Return the name of the barrier group.
|
void |
removeBarriers(long n)
Decrease the number of barriers in the group.
|
void |
removeListener(BarrierGroup.Listener listener)
Remove a listener.
|
void addListener(BarrierGroup.Listener listener)
listener - The listener.void removeListener(BarrierGroup.Listener listener)
listener - The listener.void addBarrier()
throws CommunicationException
CommunicationException - If the operation could not be completed due to a network
communication problem. The barrier group is left in an unknown
state.IllegalStateException - If the barrier group is invalid. A group becomes invalid if
removeBarriers(long) removes all of the barriers.void removeBarriers(long n)
throws CommunicationException
n - The number of barriers to remove.CommunicationException - If the operation could not be completed due to a network
communication problem. The barrier group is left in an unknown
state.IllegalStateException - If n > N - W.void addWaiter(BarrierIdentity barrierIdentity) throws CommunicationException
barrierIdentity - Identifies the barrier.CommunicationException - If the operation could not be completed due to a network
communication problem. The barrier group is left in an unknown
state.IllegalStateException - If N == 0, or the group is invalid.void cancelWaiter(BarrierIdentity barrierIdentity) throws CommunicationException
Does nothing if the barrierIdentity refers to an unknown waiter.
This copes with the following cases:
addWaiter(net.grinder.synchronisation.messages.BarrierIdentity).barrierIdentity - Identifies the barrier.CommunicationException - If the operation could not be completed due to a network
communication problem. The barrier group is left in an unknown
state.void cancelAll()
throws CommunicationException
CommunicationException - If the operation could not be completed due to a network
communication problem. The barrier group is left in an unknown
state.String getName()
Copyright © 2000-2014. All Rights Reserved.