protected class AbstractBarrierGroups.BarrierGroupImplementation extends Object implements BarrierGroup
BarrierGroup implementation.BarrierGroup.Listener| Constructor and Description |
|---|
AbstractBarrierGroups.BarrierGroupImplementation(String name)
Constructor.
|
| 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.
|
protected Set<BarrierIdentity> |
checkCondition()
Check whether the barrier condition is satisfied.
|
protected Set<BarrierIdentity> |
clearWaiters(Set<BarrierIdentity> waiters)
Clear waiters.
|
protected void |
fireAwaken(Set<BarrierIdentity> oldWaiters)
Call the
BarrierGroup.Listener.awaken(java.util.Set<net.grinder.synchronisation.messages.BarrierIdentity>) method for all of the
listeners. |
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.
|
String |
toString() |
public AbstractBarrierGroups.BarrierGroupImplementation(String name)
name - Barrier group name.public String getName()
getName in interface BarrierGrouppublic void addListener(BarrierGroup.Listener listener)
addListener in interface BarrierGrouplistener - The listener.public void removeListener(BarrierGroup.Listener listener)
removeListener in interface BarrierGrouplistener - The listener.public void addBarrier()
throws CommunicationException
addBarrier in interface BarrierGroupCommunicationException - If the operation could not be completed due to a network
communication problem. The barrier group is left in an unknown
state.public void removeBarriers(long n)
throws CommunicationException
removeBarriers in interface BarrierGroupn - 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.public void addWaiter(BarrierIdentity barrierIdentity) throws CommunicationException
addWaiter in interface BarrierGroupbarrierIdentity - 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.public void cancelWaiter(BarrierIdentity barrierIdentity) throws CommunicationException
Does nothing if the barrierIdentity refers to an unknown waiter.
This copes with the following cases:
BarrierGroup.addWaiter(net.grinder.synchronisation.messages.BarrierIdentity).cancelWaiter in interface BarrierGroupbarrierIdentity - 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.public void cancelAll()
throws CommunicationException
cancelAll in interface BarrierGroupCommunicationException - If the operation could not be completed due to a network
communication problem. The barrier group is left in an unknown
state.protected final void fireAwaken(Set<BarrierIdentity> oldWaiters)
BarrierGroup.Listener.awaken(java.util.Set<net.grinder.synchronisation.messages.BarrierIdentity>) method for all of the
listeners.oldWaiters - The previous waiters.protected final Set<BarrierIdentity> clearWaiters(Set<BarrierIdentity> waiters)
waiters - Waiters to removed, if they exist.protected final Set<BarrierIdentity> checkCondition()
The caller is responsible for taking whatever other action necessary such as notifying the listeners.
Copyright © 2000-2014. All Rights Reserved.