hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: HttpAsyncContentProducer & IOControl
Date Wed, 03 Oct 2012 18:21:22 GMT
On Wed, 2012-10-03 at 12:59 -0400, Bill Speirs wrote:
> I'm working on implementing an HttpAsyncContentProducer. The content
> requires some blocking to produce, so instead of tying up the IO thread, I
> *believe* I need to use the IOControl method suspendOutput() to prevent
> future calls to produceContent(). However this opens up the question, how
> do I inform the IO thread to start calling produceContent() again? Do I
> need to save a reference to the IOControl object in the thread producing
> the content, and then have that thread call requestOutput()?
> 

Yes, that is what you should be doing. Essentially, what you need a
shared buffer protected by a mutex used by the I/O reactor to read data
from or write data to the underlying connection and by a worker thread
to produce data to or consume data from the buffer.

http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedInputBuffer.java
http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/util/SharedOutputBuffer.java


> Essentially, what would the pseudocode look like for
> an HttpAsyncContentProducer that must block to product it's content?
> 
> Thanks!
> 
> Bill-

There are currently no good examples in HC, unfortunately. A good
reference implementation can be the async HTTP client conduit in Apache
CXF:

http://svn.apache.org/repos/asf/cxf/trunk/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/

Hope this helps

Oleg 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message