Open AndreasPK opened 4 years ago
Following https://www.snoyman.com/blog/2016/11/haskells-missing-concurrency-basics/, let's reopen this. I think the mitigation with length ps < 1024 = hPut h (ps
snoc0x0a)
is both insufficient and inefficient.
I am looking at the implementation of hPutStrLn
and do not see an easy solution without copying. Perhaps, adding hPutStrLnAtomic
is the solution.
A related discussion https://discourse.haskell.org/t/explain-ghc-internal-io-handle-text-hputstr/9389
Since the newline is added in an additional hPut call another thread might write to the handle in the meantime.
I think that's acceptable but should be documented.