Atmosphere/wasync — pull request #29 by thabach (2013-04-19 10:57:11+00:00)
Title: Proposal for staged, serialized fire()s.

Hi Jeanfrancois

here comes my proposal for staged, serialized ```fire()```s.

It allows for asynchronous, non-blocking but still sequential ```fire()```s. The implementation in the pull-request ...

... plays nice with :
- [x] the AHC connection pool, by not constantly pinning a connection but returning it to the pool after each POST.
- [x] wasync configurability in that it allows for other more performance optimized, custom implementations of ```ISerializedFireStage```. The current implementation coming with this request (```DefaultSerializedFireStage```) allocates one dedicated ```Thread``` per stage instance.

... takes care of :
- [x] serialization (preserve the ordering) of ```fire()```-calls
- [x] batching of binary payloads of multiple subsequent ```fire```-calls

... but needs :
- [x] some (minor) signature changes in top-level interfaces
- [x] a generic implementation of a ```Future```, which in the pull-request comes from Google guava.

Further, the current implementation of ```SequentialHTTPSocket``` has duplicated code from ```DefaultSocket```, which should be refactored into a common base class, if the proposal was to be put into wasync for real.

The proposal does expose two new abstractions on the API level, the ```SequentialHTTPClient``` and the ```DefaultSerializedFireStage```. A client can be bootstrapped like this:

```java
_client = ClientFactory.getDefault().newClient(SequentialHTTPClient.class);
ISerializedFireStage serializedFireStage = new DefaultSerializedFireStage();
_socket = _client.create(new Options.OptionsBuilder().serializedFireStage(serializedFireStage).build());
```

Looking forward to your comments, cheers, Christian.