Re: [Simpleweb-Support] Disconnect processing thread from request/socket?
Brought to you by:
niallg
From: Alex C. <al...@cl...> - 2005-05-04 21:10:51
|
Niall Gallagher wrote: >Look at simple.http.load.ActiveService, it does >exactly what you want. In response to your last >question, I think that offloading the back-end IO to a >non-blocking system would be a win. I see no >difference in a proxy acting as a client versus a >non-proxy server. If you reverse the processing >technique used by Simple I think you would have a very >efficient proxy server. I have thought about such a >proxy server in the past, however I have not had time >to implement it even though I am sure you could modify >simple.http.* to achieve it. > > Niall, Thanks for your response. I can see from the source code that ActiveService always spawns a new thread, obviously it would be better to make use of a thread pool, but that should be a pretty simple change. It's not obvious how the IO layer knows when the service's response is complete; the Thread isn't visible, so you can't join() it, and there's no FutureResult or similar handle for polling... OK, never mind, I just found the OutputMonitor. :) Interesting design choice to have the OutputStream drive the completion. So it looks like I could give the Request and Response to some other thread and have the Service's thread forget about them entirely--the IO layer would detect when the response was considered to be complete and adopt the response (carrying its socket in tow) at that point. -0xe1a |