[Haskell] [Haskell-cafe] ANN: Monad.Reader Issue 19

Bas van Dijk v.dijk.bas at gmail.com
Wed Oct 26 22:24:56 CEST 2011


On 26 October 2011 21:17, Brent Yorgey <byorgey at seas.upenn.edu> wrote:
> I am pleased to announce that Issue 19 of The Monad.Reader, a special
> issue on parallelism and concurrency, is now available:

Thanks, I always really enjoy The Monad.Reader.

> Issue 19 consists of the following three articles:
>
>  * Mighttpd – a High Performance Web Server in Haskell
>    by Kazu Yamamoto

Kazu, really interesting article!

I have one question regarding your use of atomicModifyIORef:

  x <- atomicModifyIORef ref (\_ -> (tmstr, ()))
  x `seq` return ()

Can't you write that as just: writeIORef ref tmstr? If you're not
using the previous value of the IORef there's no chance of
inconsistency.

I looked in the git repository of mighttpd2 and it seems that in the
FileCache module we can make a similar change by rewriting:

remover :: IORef Cache -> IO ()
remover ref = do
    threadDelay 10000000
    _ <- atomicModifyIORef ref (\_ -> (M.empty, ()))
    remover ref

to:

remover :: IORef Cache -> IO ()
remover ref = forever $ do
    threadDelay 10000000
    writeIORef ref M.empty

Regards,

Bas



More information about the Haskell mailing list