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

xapi.process.api.ProcessCursor Maven / Gradle / Ivy

There is a newer version: 0.5
Show newest version
package xapi.process.api;

import java.io.Serializable;
import java.util.Iterator;

import xapi.inject.impl.LazyPojo;
import static xapi.util.X_Util.equal;

/**
 * A state-blob for creating a resumable operation, most often sent to you by an
 * exception, or thrown by you via a RescheduleException.
 *
 * @author "James X. Nelson ([email protected])"
 */
public class ProcessCursor  {

  private transient Iterable stages;
  private final LazyPojo> path;

  public ProcessCursor(Iterable path, int size) {
    this.stages = path;
    this.path = new LazyPojo>() {
      @Override
      protected java.util.Iterator initialValue() {
        if (stages == null) {

        }
        return stages.iterator();
      };
    };
  }

  K[] done;
  K[] todo;
  int position;

  int maxTries = 3;
  int tries = 1;

  public void bump() {
  }

  public boolean ifNext(K position) {
    if (equal(todo[this.position], position)) {
      bump();
      return true;
    }
    return false;
  }

  public void skip(K position) {
  }

  @Override
  protected void finalize() throws Throwable {
    stages = null;
    path.reset();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy