Folks,
I have a thread that launches socket reader and writer threads. My
intent is to notify the main thread when an exception is caught by
the reader/writer. Is this code proper?
---
withException :: (Event a -> IO ())
-> IO ()
-> IO Bool
withException post action =
handle (\e -> do case e of
AsyncException ThreadKilled -> return ()
_ -> post $ NetworkError e
return False
) $ do { action; return True }
writeLoop :: (Event a -> IO ()) -> Handle -> (SSL, BIO, BIO) -> IO ()
writeLoop post h ssl =
do go <- withException post $
do cmd <- read h ssl
post $! Cmd $! cmd
when go $ writeLoop post h ssl
---
Thanks, Joel
--
http://wagerlabs.com/
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe