DGP - merged printing support from branch
[debian/openrocket] / src / net / sf / openrocket / optimization / general / ParallelFunctionCache.java
1 package net.sf.openrocket.optimization.general;
2
3 import java.util.Collection;
4 import java.util.List;
5
6 /**
7  * A FunctionCache that allows scheduling points to be computed in the background,
8  * waiting for specific points to become computed or aborting the computation of
9  * points.
10  * 
11  * @author Sampo Niskanen <sampo.niskanen@iki.fi>
12  */
13 public interface ParallelFunctionCache extends FunctionCache {
14         
15         /**
16          * Schedule a list of function evaluations at the specified points.
17          * The points are added to the end of the computation queue in the order
18          * they are returned by the iterator.
19          * 
20          * @param points        the points at which to evaluate the function.
21          */
22         public void compute(Collection<Point> points);
23         
24         /**
25          * Schedule function evaluation for the specified point.  The point is
26          * added to the end of the computation queue.
27          * 
28          * @param point         the point at which to evaluate the function.
29          */
30         public void compute(Point point);
31         
32         /**
33          * Wait for a collection of points to be computed.  After calling this method
34          * the function values are available by calling {@link #getValue(Point)}.
35          * 
36          * @param points        the points to wait for.
37          * @throws InterruptedException         if this thread or the computing thread was interrupted while waiting.
38          */
39         public void waitFor(Collection<Point> points) throws InterruptedException, OptimizationException;
40         
41         /**
42          * Wait for a point to be computed.  After calling this method
43          * the function value is available by calling {@link #getValue(Point)}.
44          * 
45          * @param point         the point to wait for.
46          * @throws InterruptedException         if this thread or the computing thread was interrupted while waiting.
47          * @throws OptimizationException 
48          */
49         public void waitFor(Point point) throws InterruptedException, OptimizationException;
50         
51         
52         /**
53          * Abort the computation of the specified points.  If computation has ended,
54          * the result is stored in the function cache anyway.
55          * 
56          * @param points        the points to abort.
57          * @return                      a list of the points that have been computed anyway
58          */
59         public List<Point> abort(Collection<Point> points);
60         
61         
62         /**
63          * Abort the computation of the specified point.  If computation has ended,
64          * the result is stored in the function cache anyway.
65          * 
66          * @param point         the point to abort.
67          * @return                      <code>true</code> if the point has been computed anyway, <code>false</code> if not.
68          */
69         public boolean abort(Point point);
70 }