cz.cuni.amis.utils.flag
Class Flag.DoInSync<T>

Package class diagram package Flag.DoInSync
java.lang.Object
  extended by cz.cuni.amis.utils.flag.Flag.DoInSync<T>
Type Parameters:
T -
Direct Known Subclasses:
FlagInteger.DoInSyncWithReason
Enclosing class:
Flag<T>

public abstract static class Flag.DoInSync<T>
extends Object

Usage of this abstract class is as simple as it could be ... all you have to do is to instantiate it (using anonymous objects).

Example:

Flag<Integer> flag = new Flag<Integer>(10);

flag.inSync( new Flag.DoInSync<Integer>(flag) {

public abstract void execute(Integer flagValue) {

setFlag(flagValue+1);

}

} );

No need to do anything else! The class will submit itself to the flag upon construction.

Use it to create correct counters (or use directly FlagInteger class).

Author:
Jimmy

Constructor Summary
Flag.DoInSync()
           
 
Method Summary
abstract  void execute(T flagValue)
           
protected  T getFlag()
           
protected  boolean isImmutable()
          Tells you whether you operate over immutable flag (can't call setFlag() then) or not.
protected  void setFlag(T value)
          Set value in sync.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Flag.DoInSync

public Flag.DoInSync()
Method Detail

isImmutable

protected boolean isImmutable()
Tells you whether you operate over immutable flag (can't call setFlag() then) or not.

Returns:

setFlag

protected void setFlag(T value)
Set value in sync.


getFlag

protected T getFlag()

execute

public abstract void execute(T flagValue)
Parameters:
flag -


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