ocaml-cohttp icon indicating copy to clipboard operation
ocaml-cohttp copied to clipboard

Use lwt_io.is_closed where appropriate

Open mseri opened this issue 4 years ago • 2 comments

mseri avatar Jan 16 '22 18:01 mseri

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 ...?

mseri avatar Jan 18 '22 21:01 mseri

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.

rgrinberg avatar Apr 23 '22 18:04 rgrinberg