]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.utils/src/org/simantics/utils/IOperation.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.utils / src / org / simantics / utils / IOperation.java
diff --git a/bundles/org.simantics.utils/src/org/simantics/utils/IOperation.java b/bundles/org.simantics.utils/src/org/simantics/utils/IOperation.java
new file mode 100644 (file)
index 0000000..1ffcc34
--- /dev/null
@@ -0,0 +1,29 @@
+package org.simantics.utils;\r
+\r
+/**\r
+ * An asynchronous operation returning some result.\r
+ * \r
+ * @author Hannu Niemistö\r
+ */\r
+public interface IOperation<Result, E extends Exception> {\r
+    /**\r
+     * Waits that operation is completed. Either returns the\r
+     * result or throws an exception if the operation fails.\r
+     * If operation has already been completed when the method is called,\r
+     * returns immediately.\r
+     */\r
+    Result waitFor() throws E;\r
+\r
+    /**\r
+     * Tells whether the operation is already completed.\r
+     */\r
+    boolean isDone();\r
+\r
+    /**\r
+     * Adds a listener that is notified when the operation\r
+     * is completed. If the operation has already been completed\r
+     * when the method is called, calls the listener immediately\r
+     * (but asynchronously).\r
+     */\r
+    void addListener(IOperationListener<Result, E> listener);\r
+}
\ No newline at end of file