It is pretty straight forward to set up....

interface Progress extends Callable<Map> {
   void setInput( Map );
   Map call() throws Exception;
}

The hard part is making "some kind of future that can report on 
progress"....

Right now the relationship between Future and Callable is handled as by 
the Executor; literally the Executor schedules the Callable; and returns 
a Future (basically a callback object) allowing client code to stop the 
thing. The Callable is controled by means of (shock!) the Thread api - 
the hard bit of programming is in the Future that has to be very careful 
to only Interrupt the Thread once.

Here is the code:
>         boolean innerCancel(boolean mayInterruptIfRunning) {
>         for (;;) {
>         int s = getState();
>         if (ranOrCancelled(s))
>             return false;
>         if (compareAndSetState(s, CANCELLED))
>             break;
>         }
>             if (mayInterruptIfRunning) {
>                 Thread r = runner;
>                 if (r != null)
>                     r.interrupt();
>             }
>             releaseShared(0);
>             done();
>             return true;
>         }
Notice that the runnable does not know about the Future; and vice versa.

In order to report on Progress (at all), let alone decompose Progress 
into bite sized chunks as we delegate to different methods ... we need 
to somehow let the Callable communicate with the outside world... 
basically it needs a reference to the Future that is "watching" it.

Does anyone have ideas on this one?
Jody


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to