jsr340-experts@servlet-spec.java.net

[jsr340-experts] async IO and flush?

From: Greg Wilkins <gregw_at_intalio.com>
Date: Thu, 23 May 2013 10:26:49 +1000

How is flush() meant to work with async IO?


Currently I'm still implementing an aggregating buffer with asyncIO, so
that if you do:

 write(one_byte);

it is just copied into the aggregate buffer, no IO is actually done and
isReady() will return true.
IO is only actually done when the buffer fills up and only then might
isReady() return false.

So should flush() block until all content is written? or should it also
work in async mode so that you can call isReady() after a flush() and if
isReady returns false then onWritePossible() will be called once the flush
is complete?

Also when can flush() be called? can it be called if isReady() has
returned false an OWP has not been called? can it be called before a call
to isReady()?


I think flush() should be treated exactly like a write, because making it
blocking has all the problems of autoblocking.


ACTION OPEN ASYNC READY PENDING
UNREADY
-------------------------------------------------------------------------------
setWriteListener() READY->owp ise ise ise
ise
write() OPEN ise PENDING wpe
wpe
flush() OPEN ise PENDING wpe wpe
isReady() OPEN:true READY:true READY:true UNREADY:false
UNREADY:false
write completed - - - ASYNC
READY->owp


cheers




-- 
Greg Wilkins <gregw_at_intalio.com>
http://www.webtide.com
Developer advice and support from the Jetty & CometD experts.
Intalio, the modern way to build business applications.