Async Futures / by Your Name

An API extension for Java Futures and Non-Blocking + Asynchronous I/O (and possibly other use-cases).

AsyncFutures are something I came up with during my time at LimeWire when I was working on the Mojito DHT and they are conceptually very similar to Apache MINA's IoFutures. The very basic idea of an AsyncFuture is that it decouples starting and returning a value from each other. A simple example would be sending a message from one Thread and receiving the response from an another Thread. With a standard Future one would have to put the first Thread into waiting state before the Runnable or Callable objects return, wait for the response and notify the waiting Thread when the response arrives. It works but doesn't scale very well if large amounts of messages need to be sent as each request will require its own Thread.

In addition, AsyncFutures have built-in support for timeouts and callbacks. Timeouts ensure that all operations are deterministic in terms of the time they need to complete and callbacks enable the user to receive completion events instead of having to wait for the Futures to complete.

NOTE+CAUTION: An AsyncFuture is not an 100% compatible drop-in replacement for Futures. To be more precise, the locking methodologies of AsyncFutureTask and FutureTask are fundamentally different which leads to a slightly different AsyncFuture behavior if it's used outside of its originally intended use-case context (non-blocking computations).

UPDATE: As of Version 0.4 AsyncFutureTask may be used as a drop-in replacement for FutureTasks.

For further information and a download link see here: Async-Future