
Adam Langley ha scritto:
On Mon, Mar 31, 2008 at 12:00 PM, Manlio Perillo
wrote: Since Nginx is asynchronous, how can be solved the producer-consumer problem (that is, the Haskell program produces more data that Nginx can send to the client without blocking)?
I assume that the Haskell process is connected to nginx over a pipe or socket.
No, the idea is to have the Haskell application embedded in nginx.
In which case, nginx can use flow control to block the sending side of the pipe and the Haskell code will backup on that.
If many connections need to be multiplexed over the same flow-controlled entity (i.e. a pipe), without head-of-line blocking then you can just suspend the current thread using an MVar or the STM objects.
Alternatively, with Network.MiniHTTP the problem is turned inside out. Request handlers give return a Source object, which can be asked to generate more data on request. This would be similar to generators in Python.
This (the first suggestion) seems very interesting, thanks.
AGL
Manlio Perillo