On 10/20/2015 12:49 PM, Simone Bordet wrote:
if (cs != null) {
cs.thenAccept(cb -> {
if (cb != null) {
.... return*message* to buffer pool ...
}
});
}
At that point, the return value of onText() could well be a CF<?> like
it already is, no ?
The implementation would just need to test for null, but then never
actually use the returned object wrapped by the CF.
What do you think ?
There is one advantage to having CompletionStage<CharBuffer> return
value instead of CompletionStage<?> or CompletionStage<Boolean>. In
above example, the lambda has to capture the *message* and retain it
until the call-back happens at which point it may be that *message* has
to be ignored (not recycled). In such case the *message* may have been
retained by lambda for more time than necessary. If
CompletionStage<CharBuffer> is used instead, the buffer or null is
passed to lambda so buffer's retention time is always optimal.
Regards, Peter