Skip to content

Commit

Permalink
Merge pull request #259 from Bodigrim/interleaving-hPutStrLn
Browse files Browse the repository at this point in the history
Document possible interleaving of hPutStrLn
  • Loading branch information
Bodigrim authored Aug 23, 2020
2 parents 204b458 + c63d5cf commit cb85f82
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Data/ByteString.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1660,7 +1660,10 @@ hPutNonBlocking h bs@(BS ps l) = do
hPutStr :: Handle -> ByteString -> IO ()
hPutStr = hPut

-- | Write a ByteString to a handle, appending a newline byte
-- | Write a ByteString to a handle, appending a newline byte.
--
-- Unlike 'hPutStr', this is not atomic: other threads might write
-- to the handle between writing of the bytestring and the newline.
hPutStrLn :: Handle -> ByteString -> IO ()
hPutStrLn h ps
| length ps < 1024 = hPut h (ps `snoc` 0x0a)
Expand All @@ -1670,7 +1673,10 @@ hPutStrLn h ps
putStr :: ByteString -> IO ()
putStr = hPut stdout

-- | Write a ByteString to stdout, appending a newline byte
-- | Write a ByteString to stdout, appending a newline byte.
--
-- Unlike 'putStr', this is not atomic: other threads might write
-- to stdout between writing of the bytestring and the newline.
putStrLn :: ByteString -> IO ()
putStrLn = hPutStrLn stdout

Expand Down

0 comments on commit cb85f82

Please sign in to comment.