]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils/src/org/simantics/utils/IOperation.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.utils / src / org / simantics / utils / IOperation.java
1 package org.simantics.utils;
2
3 /**
4  * An asynchronous operation returning some result.
5  * 
6  * @author Hannu Niemistö
7  */
8 public interface IOperation<Result, E extends Exception> {
9     /**
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.
14      */
15     Result waitFor() throws E;
16
17     /**
18      * Tells whether the operation is already completed.
19      */
20     boolean isDone();
21
22     /**
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).
27      */
28     void addListener(IOperationListener<Result, E> listener);
29 }