On Wed, Aug 6, 2008 at 1:43 PM, Dain Sundstrom <[EMAIL PROTECTED]> wrote:
> On Aug 6, 2008, at 10:14 AM, Jarek Gawor wrote:
>
>> On Wed, Aug 6, 2008 at 1:00 PM, Dain Sundstrom <[EMAIL PROTECTED]> wrote:
>>>
>>> On Aug 5, 2008, at 1:25 PM, David Jencks wrote:
>>>
>>>> Is there something similar in the ee concurrency spec?
>>>
>>> Never heard of that spec.  Do you have any details?
>>
>> Here's some info on the spec:
>>
>> http://gee.cs.oswego.edu/dl/concurrencyee-interest/index.html
>>
>> http://www.jcp.org/en/jsr/detail?id=236
>>
>> and in Geronimo (trunk) we have a basic implementation of the draft spec.
>
> Interesting.  It would be nice if there were something like this for the
> client side.  One big I issue I see with EJB async methods is there is no
> way to be notified when the result of an async method is ready.  This API is
> very close to being what we would need.  Specifically this method on
> ManagedExecutorService:
>
>        submit(Callable<T> task, ManagedTaskListener taskListener)
>
> which adds a task to run with a listener for it's completion.  For async
> result support we would need something like this:
>
>        waitForResult(Future<?> future, ManagedTaskListener taskListener)

There is ManagedExecutorService.invokeAll(Collection<Callable> tasks,
ManagedTaskListener listener) function which effectively does two
things: 1) it submits the tasks and 2) waits until they all finish.
Pretty much the same as ExecutorService.invokeAll() except the
listener which you could use to figure out which task completed so
far.

> of maybe
>
>        submit(new WaitForCallable(myFuture), taskListener)
>
> If the future instance implemented a special "notifiable" interface, the
> Executor service would simply add the listener to the future.  If it didn't
> implement that interface, it would use a thread to block (or periodically
> poll) for the result.

I don't know the OpenEJB code very well, but what if it returned a
Callable object instead of a Future. That way, I think, it would fit
nicely with either ExecutorService or ManagedExecutorService. And as
you mentioned, you could always wrap a Future into a Callable or
Runnable.

> Something like this would allow users to write efficient and spec compliant
> async clients.
>
> David (Jencks), are you working on this spec?  Any chances on getting
> something like this in?

I'm working on the spec and the implementation in Geronimo and just
joined the Expert Group so if you have any comments or specific
proposals please let me know.

Jarek

Reply via email to