JAL - 3690 AlignCalc rebuilt - FutureTask-based manager
[jalview.git] / src / jalview / api / AlignCalcWorkerI.java
index 1387cba..1184853 100644 (file)
  */
 package jalview.api;
 
+import java.util.concurrent.Callable;
+
 import jalview.datamodel.AlignmentAnnotation;
 
 /**
  * Interface describing a worker that calculates alignment annotation(s). The
  * main (re-)calculation should be performed by the inherited run() method.
  */
-public interface AlignCalcWorkerI extends Runnable
+public interface AlignCalcWorkerI extends Callable<Void>
 {
   /**
    * Answers true if this worker updates the given annotation (regardless of its
@@ -48,7 +50,24 @@ public interface AlignCalcWorkerI extends Runnable
    * Removes any annotation(s) managed by this worker from the alignment
    */
   void removeAnnotation();
-
+  
+  
+  /**
+   * Default implementation of call which calls run and propagates the
+   * exception.
+   */
+  @Override
+  public default Void call() throws Exception
+  {
+    run();
+    return null;
+  }
+  
+  /**
+   * The main calculation happens here
+   */
+  public void run() throws Exception;
+  
   /**
    * Answers true if the worker should be deleted entirely when its annotation
    * is deleted from the display, or false if it should continue to run. Some