1 package org.simantics.utils;
4 * An asynchronous operation returning some result.
6 * @author Hannu Niemistö
8 public interface IOperation<Result, E extends Exception> {
10 * Waits that operation is completed. Either returns the
11 * result or throws an exception if the operation fails.
12 * If operation has already been completed when the method is called,
13 * returns immediately.
15 Result waitFor() throws E;
18 * Tells whether the operation is already completed.
23 * Adds a listener that is notified when the operation
24 * is completed. If the operation has already been completed
25 * when the method is called, calls the listener immediately
26 * (but asynchronously).
28 void addListener(IOperationListener<Result, E> listener);