JAL-961, JAL-1115 - pending test to ensure only one worker waits around for another...
[jalview.git] / src / jalview / api / AlignCalcManagerI.java
1 package jalview.api;
2
3 import java.util.List;
4
5 import jalview.datamodel.AlignmentAnnotation;
6
7 public interface AlignCalcManagerI
8 {
9
10
11   /**
12    * tell manager that a worker is initialised and has started to run
13    * @param worker
14    */
15   void notifyStart(AlignCalcWorkerI worker);
16
17   /**
18    * check if a calculation of this type is already active
19    * @param worker
20    * @return
21    */
22   boolean alreadyDoing(AlignCalcWorkerI worker);
23
24   /**
25    * tell manager that worker is now processing data
26    * @param worker
27    */
28   boolean notifyWorking(AlignCalcWorkerI worker);
29
30
31   /**
32    * notify manager that the worker has completed, and results may be ready to collect
33    * @param worker
34    */
35   void workerComplete(AlignCalcWorkerI worker);
36
37   /**
38    * indicate that a worker like this cannot run on the platform and shouldn't be started again
39    * @param worker
40    */
41   void workerCannotRun(AlignCalcWorkerI worker);
42
43   /**
44    * indicate that a worker like this may be run on the platform.
45    * @param worker of class to be removed from the execution blacklist
46    */
47   void workerMayRun(AlignCalcWorkerI worker);
48   /**
49    * launch a new worker
50    * @param worker
51    */
52   void startWorker(AlignCalcWorkerI worker);
53
54   /**
55    *
56    * @param worker
57    * @return
58    */
59   boolean isWorking(AlignCalcWorkerI worker);
60
61   /**
62    * if any worker thread is operational, return true!
63    * @return
64    */
65   boolean isWorking();
66
67
68   /**
69    * register a restartable worker
70    * @param worker
71    */
72   void registerWorker(AlignCalcWorkerI worker);
73
74   /**
75    * restart any registered workers
76    */
77   void restartWorkers();
78
79   /**
80    *
81    * @param alignmentAnnotation
82    * @return true if a currently registered and working worker indicates its involvement with the given alignmentAnnotation
83    */
84   boolean workingInvolvedWith(AlignmentAnnotation alignmentAnnotation);
85
86   /**
87    * kick any known instances of the given worker class to update their annotation
88    * @param workerClass
89    */
90   void updateAnnotationFor(Class workerClass);
91
92   /**
93    * return any registered workers of the given class
94    * @param workerClass
95    * @return null or one or more workers of the given class
96    */
97   List<AlignCalcWorkerI> getRegisteredWorkersOfClass(
98           Class workerClass);
99
100   /**
101    * start any workers of the given class
102    * @param workerClass
103    * @return false if no workers of given class were registered
104    * (note - blacklisted classes cannot be restarted, so this method will return true for blacklisted workers)
105    */
106   boolean startRegisteredWorkersOfClass(Class workerClass);
107
108   /**
109    * work out if there is an instance of a worker that is *waiting* to start
110    * calculating
111    *
112    * @param workingClass
113    * @return true if workingClass is already waiting to calculate. false if it
114    *         is calculating, or not queued.
115    */
116   boolean isPending(AlignCalcWorkerI workingClass);
117
118 }