ocaml-cohttp
ocaml-cohttp copied to clipboard
Use lwt_io.is_closed where appropriate
I did it on a branch, the code is uglier and I don't really see the benefit. Is rasing and catching an exception in Lwt so much slower than an if Lwt.is_closed then ... else ...?
Raising and catching an exception is surely much slower than a conditional. But I'm not sure if it's the same change semantically.
if Lwt.is_closed t then foo t
introduces a race because t can be closed before foo actually tries the write.
I suppose the initial check is a decent optimization though.