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

java.lang.Object
  extended by cz.cuni.amis.pogamut.base.component.bus.event.WaitForEvent

public class WaitForEvent
extends java.lang.Object

Allows you to wait for some event on the bus.

WARNING: if you want to stop using this object (throw away the pointer) call DESTROY(), you will usually use try{}finally{} for this.


Nested Class Summary
static interface WaitForEvent.IEventFilter<T>
          Note that only events that implements IComponentEvent may be really substitued as T.
 
Constructor Summary
WaitForEvent(IComponentBus bus, WaitForEvent.IEventFilter accept)
           
 
Method Summary
 boolean await()
          Awaits the event (forever) ...
 boolean await(long timeoutMillis)
          Awaits the event for a specific amount of time.
 void destroy()
          Destroys the object ...
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WaitForEvent

public WaitForEvent(IComponentBus bus,
                    WaitForEvent.IEventFilter accept)
Method Detail

await

public boolean await()
              throws PogamutInterruptedException
Awaits the event (forever) ... do not use! Always use version with timeout!

Returns:
whether the event has been received (false == fatal error happened)
Throws:
PogamutInterruptedException

await

public boolean await(long timeoutMillis)
              throws PogamutInterruptedException
Awaits the event for a specific amount of time.

WARNING: If the event is not received and you do not plan to use the object further - call destroy()!

Parameters:
timeoutMillis -
Returns:
whether the event has been received (false == timeout or fatal error has happened)
Throws:
java.lang.InterruptedException
PogamutInterruptedException

destroy

public void destroy()
Destroys the object ... any await() call will just go through after this call.