Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

27 lines (20 sloc) 0.598 kb
module WorkQueue where
import Prelude
import Control.Concurrent
import qualified Control.Exception as E
import Control.Monad.Trans.Resource (ResourceT, runResourceT)
newtype Queue = Queue (Chan (ResourceT IO ()))
makeQueue :: IO Queue
makeQueue = do
chan <- newChan
let handleE :: E.SomeException -> IO ()
handleE = print
loop =
do f <- readChan chan
E.catch (runResourceT f) handleE
_ <- forkIO loop
return $ Queue chan
enqueue :: Queue -> ResourceT IO () -> IO ()
enqueue (Queue chan) =
writeChan chan
Jump to Line
Something went wrong with that request. Please try again.