summaryrefslogtreecommitdiff
path: root/testsuite/tests/concurrent/should_run/allowinterrupt001.hs
blob: 938aa653836dc5c2e2f998ea03d19a6e9e06138f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
import Control.Exception
import Control.Concurrent
import GHC.Conc
import Control.Monad

nfib n = if n < 2 then 1 else nfib (n-2) + nfib (n-1)

main = do
   t <- mask_ $ forkIO $ forM_ [1..] $ \n -> nfib n `seq` allowInterrupt
   killThread t
   let loop = do r <- threadStatus t
                 when (r /= ThreadFinished) $ do yield; loop
   loop