Pipelining is sending multiple requests over a socket and receiving the responses later, in the same order. This is faster than sending one request, waiting for the response, then sending the next request, and so on. This implementation returns a promise (future) response for each request that when invoked waits for the response if not already arrived. Multiple threads can send on the same pipeline (and get promises back); it will pipeline each thread's request right away without waiting.
A pipeline closes itself when a read or write causes an error, so you can detect a broken pipeline by checking isClosed. It also closes itself when garbage collected, or you can close it explicitly.
Pipeline
newPipeline :: MonadIO m => Connection i o -> m (Pipeline i o)Source
Create new Pipeline on given connection. You should close
pipeline when finished, which will also close connection. If pipeline is not closed but eventually garbage collected, it will be closed along with connection.
send :: Pipeline i o -> i -> IOE ()Source
Send message to destination; the destination must not response (otherwise future call
s will get these responses instead of their own).
Throw IOError and close pipeline if send fails
call :: Pipeline i o -> i -> IOE (IOE o)Source
Send message to destination and return promise of response from one message only. The destination must reply to the message (otherwise promises will have the wrong responses in them). Throw IOError and closes pipeline if send fails, likewise for promised response.