module TextShow.Control.Concurrent () where
import Data.Monoid.Compat ((<>))
import Data.Text.Lazy.Builder (fromString)
import Foreign.C.Types
import GHC.Conc (BlockReason, ThreadStatus)
import GHC.Conc.Sync (ThreadId(..))
import GHC.Prim
import TextShow.Classes (TextShow(..))
import TextShow.Foreign.C.Types ()
import TextShow.TH.Internal (deriveTextShow)
instance TextShow ThreadId where
showbPrec p t = fromString "ThreadId " <> showbPrec p (getThreadId t)
foreign import ccall unsafe "rts_getThreadId" getThreadId# :: Addr# -> CInt
getThreadId :: ThreadId -> CInt
getThreadId (ThreadId tid) = getThreadId# (unsafeCoerce# tid)
$(deriveTextShow ''ThreadStatus)
$(deriveTextShow ''BlockReason)