All Downloads are FREE. Search and download functionalities are using the official Maven repository.

water.TAtomic Maven / Gradle / Ivy

There is a newer version: 3.8.2.9
Show newest version
package water;

/**
 *  A typed atomic update.
 */
public abstract class TAtomic extends Atomic> {
  public TAtomic(){}
  public TAtomic(H2O.H2OCountedCompleter completer){super(completer);}
  /** Atomically update an old value to a new one.
   *  @param old  The old value, it may be null.  It is a defensive copy.
   *  @return The new value; if null if this atomic update no longer needs to be run
   */
  protected abstract T atomic(T old);

  @Override protected Value atomic(Value val) {
    T old = val == null ? null : (T)(val.getFreezable().clone());
    T nnn = atomic(old);
    // Atomic operation changes the data, so it can not be performed over
    // values persisted on read-only data source as we would not be able to
    // write those changes back.
    assert val == null || val.onICE() || !val.isPersisted();
    return nnn == null ? null : new Value(_key,nnn,val==null?Value.ICE:val.backend());
  }
  @Override protected void onSuccess( Value old ) { onSuccess(old==null?null:(T)old.getFreezable()); }
  // Upcast the old value to T
  public void onSuccess( T old ) { }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy