cz.cuni.amis.pogamut.base.component.bus.event
Class BusAwareCountDownLatch

java.lang.Object
  extended by java.util.concurrent.CountDownLatch
      extended by cz.cuni.amis.pogamut.base.component.bus.event.BusAwareCountDownLatch

public class BusAwareCountDownLatch
extends java.util.concurrent.CountDownLatch

Extends CoundDownLatch with ability to stop waiting when some component connected to the bus fails which may indicate termination of all other components on the bus. Thus further waiting doesn't make sense.


Nested Class Summary
static class BusAwareCountDownLatch.BusStoppedInterruptedException
           
 
Constructor Summary
BusAwareCountDownLatch(int count, IComponentBus bus)
           
BusAwareCountDownLatch(int count, IComponentBus bus, IComponent... components)
           
BusAwareCountDownLatch(int count, IComponentBus bus, IToken... componentIds)
           
 
Method Summary
 void await()
           
 boolean await(long timeout, java.util.concurrent.TimeUnit unit)
           
protected  void checkBusStop()
           
 void countDown()
           
 java.lang.String toString()
           
 
Methods inherited from class java.util.concurrent.CountDownLatch
getCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BusAwareCountDownLatch

public BusAwareCountDownLatch(int count,
                              IComponentBus bus)

BusAwareCountDownLatch

public BusAwareCountDownLatch(int count,
                              IComponentBus bus,
                              IComponent... components)

BusAwareCountDownLatch

public BusAwareCountDownLatch(int count,
                              IComponentBus bus,
                              IToken... componentIds)
Method Detail

countDown

public void countDown()
Overrides:
countDown in class java.util.concurrent.CountDownLatch

await

public void await()
           throws BusAwareCountDownLatch.BusStoppedInterruptedException,
                  PogamutInterruptedException
Overrides:
await in class java.util.concurrent.CountDownLatch
Throws:
BusAwareCountDownLatch.BusStoppedInterruptedException - when the waiting was stopped because some component of the bus stopped
PogamutInterruptedException

await

public boolean await(long timeout,
                     java.util.concurrent.TimeUnit unit)
              throws BusAwareCountDownLatch.BusStoppedInterruptedException,
                     PogamutInterruptedException
Overrides:
await in class java.util.concurrent.CountDownLatch
Parameters:
timeout -
unit -
Returns:
Throws:
BusAwareCountDownLatch.BusStoppedInterruptedException - when the waiting was stopped because some component of the bus stopped
PogamutInterruptedException

checkBusStop

protected void checkBusStop()
                     throws BusAwareCountDownLatch.BusStoppedInterruptedException
Throws:
BusAwareCountDownLatch.BusStoppedInterruptedException

toString

public java.lang.String toString()
Overrides:
toString in class java.util.concurrent.CountDownLatch