cz.cuni.amis.utils.flag
Class WaitForFlagChange<TYPE>

Package class diagram package WaitForFlagChange
java.lang.Object
  extended by cz.cuni.amis.utils.flag.WaitForFlagChange<TYPE>
Type Parameters:
TYPE -

public class WaitForFlagChange<TYPE>
extends Object

This class is implementing the waiting on some flag value.

Note that you may call only one AWAIT() at time.

Typical usage:
boolean flagValue = new WaitForFlagChange<Boolean>(booleanFlag, Boolean.TRUE).await();
int flagValue = new WaitForFlagChange<Integer>(integerFlag, new Integer[]{1,3}).await();

Author:
Jimmy

Nested Class Summary
static interface WaitForFlagChange.IAccept<TYPE>
           
 
Constructor Summary
WaitForFlagChange(IFlag<TYPE> flag)
          Wait for the next flag change.
WaitForFlagChange(IFlag<TYPE> flag, Collection<TYPE> waitingFor)
           
WaitForFlagChange(IFlag<TYPE> flag, TYPE waitingFor)
           
WaitForFlagChange(IFlag<TYPE> flag, TYPE[] waitingFor)
           
WaitForFlagChange(IFlag<TYPE> flag, WaitForFlagChange.IAccept<TYPE> waitingFor)
           
 
Method Summary
 TYPE await()
          Note that you may call only await() from one thread! If the instance is already in used it may produce unwanted behavior (e.g.
 TYPE await(long timeout, TimeUnit timeUnit)
          Note that you may call only await() from one thread! If the instance is already in used it may produce unwanted behavior.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WaitForFlagChange

public WaitForFlagChange(IFlag<TYPE> flag)
Wait for the next flag change.

Parameters:
flag -

WaitForFlagChange

public WaitForFlagChange(IFlag<TYPE> flag,
                         WaitForFlagChange.IAccept<TYPE> waitingFor)

WaitForFlagChange

public WaitForFlagChange(IFlag<TYPE> flag,
                         TYPE waitingFor)

WaitForFlagChange

public WaitForFlagChange(IFlag<TYPE> flag,
                         TYPE[] waitingFor)

WaitForFlagChange

public WaitForFlagChange(IFlag<TYPE> flag,
                         Collection<TYPE> waitingFor)
Method Detail

await

public TYPE await()
           throws PogamutInterruptedException
Note that you may call only await() from one thread! If the instance is already in used it may produce unwanted behavior (e.g. dead-lock).

Returns:
value from the flag that raised the latch
Throws:
InterruptedException
PogamutInterruptedException

await

public TYPE await(long timeout,
                  TimeUnit timeUnit)
           throws PogamutInterruptedException
Note that you may call only await() from one thread! If the instance is already in used it may produce unwanted behavior.

Returns null if desired value hasn't been set at the flag before timeout.

Parameters:
timeout -
timeUnit -
Returns:
value of the flag
Throws:
PogamutInterruptedException


Copyright © 2014 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.