[concurrency-interest] Offering data to Futures

David M. Lloyd david.lloyd at redhat.com
Tue May 26 11:36:32 EDT 2009


On 05/25/2009 07:08 PM, karlthepagan wrote:
> As a followup to last week's great discussion of FutureTask.done() 
> callbacks I'd like to ask if anyone else has rolled their own "remote 
> Future" implementation or something which interfaces with a messaging 
> library?

While I really like the Future API as well, I've found it to be inadequate 
for I/O purposes and have "rolled my own" for I/O use.

http://docs.jboss.org/xnio/latest/api/index.html?org/jboss/xnio/IoFuture.html

The main distinctions are that cancel() cannot specify interruption, the 
operation may result in an IOException, there is much more flexibility in 
terms of how you wait for the result, and you may register one or more 
asynchronous notifiers.

The abstract implementation provides some useful methods:

http://docs.jboss.org/xnio/latest/api/index.html?org/jboss/xnio/AbstractIoFuture.html

There are three protected methods which may be used to either acknowledge 
completion, failure, or cancellation asynchronously; in addition, they 
return a boolean which can be used to indicate whether that method 
invocation was the first result (subsequent invocations are ignored and 
return false), which in many cases can eliminate extra checks in the user 
implementation code.

Hope this is helpful.

- DML



More information about the Concurrency-interest mailing list