summaryrefslogtreecommitdiff
path: root/testsuite/tests/concurrent/should_run/T9379.hs
blob: 49e6d1eaedfe156ebb0f3b069847f3f05b41dabc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import Control.Exception
import Control.Concurrent
import Control.Concurrent.STM
import Foreign.StablePtr

main :: IO ()
main = do
  tv <- atomically $ newTVar True
  _ <- newStablePtr tv
  t <- mask_ $ forkIO (blockSTM tv)
  killThread t

blockSTM :: TVar Bool -> IO ()
blockSTM tv = do
  atomically $ do
    v <- readTVar tv
    check $ not v