public final class BarrierImplementation extends Object implements Barrier, BarrierGroup.Listener
| Constructor and Description |
|---|
BarrierImplementation(BarrierGroup group,
BarrierIdentity.Factory identityFactory)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
await()
Wait until all other barriers with the same name have invoked
Barrier.await(). |
boolean |
await(long timeout)
Equivalent to
await(timeout, TimeUnit.MILLISECONDS). |
boolean |
await(long timeout,
TimeUnit unit)
Version of
Barrier.await() that allows a timeout to be specified. |
void |
awaken(Set<BarrierIdentity> waiters) |
void |
cancel()
Cancel this
Barrier and reduce the total number of instances for
the barrier name. |
String |
getName()
Return the name of the barrier.
|
public BarrierImplementation(BarrierGroup group, BarrierIdentity.Factory identityFactory) throws CommunicationException
group - Barrier group.identityFactory - Identity generator.CommunicationException - If the barrier group could not be created due to a
network communication problem.public void await()
throws CancelledBarrierException,
CommunicationException
Barrier.await().
If this barrier is not the last with the name to call await and has
not been cancelled, this method blocks until one of the
following happens:
await is called for the last barrier.cancelled.cancelled.interrupts the
current thread. In this case, the barrier instance will be
cancelled.
If this barrier is the last with the name to call await, the method
will not block. All await calls made by other threads for barriers
with the same name will complete.
await in interface BarrierCancelledBarrierException - If this barrier has been cancelled.CommunicationExceptionpublic boolean await(long timeout,
TimeUnit unit)
throws CancelledBarrierException,
CommunicationException
Barrier.await() that allows a timeout to be specified.
If the specified timeout elapses while the thread is waiting, the method
will return false, and the barrier instance will be
cancelled.
await in interface Barriertimeout - The time to wait for the barrier.unit - The time unit of the timeout parameter.false if and only if the waiting time detectably elapsed
before return from the method.CancelledBarrierException - If this barrier has been cancelled.CommunicationExceptionpublic boolean await(long timeout)
throws CancelledBarrierException,
CommunicationException
Equivalent to await(timeout, TimeUnit.MILLISECONDS).
await in interface Barriertimeout - The time to wait for the barrier.false if and only if the waiting time detectably elapsed
before return from the method.CancelledBarrierException - If this barrier has been cancelled.CommunicationExceptionpublic void awaken(Set<BarrierIdentity> waiters)
awaken in interface BarrierGroup.Listenerpublic void cancel()
throws CommunicationException
Barrier and reduce the total number of instances for
the barrier name. If another thread is waiting on this barrier instance,
it will receive a CancelledBarrierException. Otherwise, if this
was the only idle barrier, the others with the same name will be awoken.
Subsequent calls to Barrier.await() for this Barrier will result
in an CancelledBarrierException.
cancel in interface BarrierCommunicationExceptionCopyright © 2000-2014. All Rights Reserved.