summaryrefslogtreecommitdiff
path: root/src/AtomicPrint.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2026-05-08 21:59:08 +0200
committerTom Smeding <tom@tomsmeding.com>2026-05-08 21:59:08 +0200
commite3ea04d8e71370032da56ad9ea66dcb82d257812 (patch)
tree6fed059e0c394f80d800b3560980284d5d4a4113 /src/AtomicPrint.hs
parent92a9e5663540e47d1f4563aca4365ecce781205f (diff)
Instrument handler blocks
Diffstat (limited to 'src/AtomicPrint.hs')
-rw-r--r--src/AtomicPrint.hs33
1 files changed, 0 insertions, 33 deletions
diff --git a/src/AtomicPrint.hs b/src/AtomicPrint.hs
deleted file mode 100644
index 82a8552..0000000
--- a/src/AtomicPrint.hs
+++ /dev/null
@@ -1,33 +0,0 @@
-{-# OPTIONS_GHC -fno-full-laziness -fno-cse #-}
-module AtomicPrint (
- atomicPrint, atomicPrintS,
- atomicPrintNoWait, atomicPrintNoWaitS,
-) where
-
-import Control.Concurrent
-import Control.Monad (void)
-import Data.Text qualified as T
-import Data.Text.IO.Utf8 qualified as T
-import Data.Text (Text)
-import System.IO
-import System.IO.Unsafe (unsafePerformIO)
-
-
-{-# NOINLINE mutex #-}
-mutex :: MVar ()
-mutex = unsafePerformIO (newMVar ())
-
-atomicPrintS :: String -> IO ()
-atomicPrintS = atomicPrint . T.pack
-
-atomicPrint :: Text -> IO ()
-atomicPrint text =
- withMVar mutex $ \() ->
- T.putStrLn text >> hFlush stdout
-
-atomicPrintNoWaitS :: String -> IO ()
-atomicPrintNoWaitS = atomicPrintNoWait . T.pack
-
--- | Does not block, so if you've masked exceptions, nothing will come through here
-atomicPrintNoWait :: Text -> IO ()
-atomicPrintNoWait text = void $ forkIO $ atomicPrint text