1 {-# OPTIONS -fglasgow-exts #-}
8 -- Raise an exception in another thread. We need a lot of synchronisation here:
10 -- - an MVar for the second thread to block on which it waits for the
13 -- - an MVar to signal the main thread that the second thread is ready to
14 -- accept the signal (ready)
16 -- - an MVar to signal the main thread that the second thread has received
17 -- the signal (ready2). If we don't have this MVar, then the main
18 -- thread could exit before the second thread has time to print
24 ready2 <- newEmptyMVar
25 id <- forkIO (Exception.catch (putMVar ready () >> takeMVar block)
26 (\e -> putStr (show e) >> putMVar ready2 ()))
28 throwTo id (ErrorCall "hello")