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: [email protected] For additional commands, e-mail: [email protected]
