diff options
author | Andrea Rossato <andrea.rossato@ing.unitn.it> | 2007-10-11 22:30:29 +0200 |
---|---|---|
committer | Andrea Rossato <andrea.rossato@ing.unitn.it> | 2007-10-11 22:30:29 +0200 |
commit | 7064cb084ea05f13a54ec7cfb2956f5ade5458ba (patch) | |
tree | f6dd4a50bf3e64dec5afb416a118a047ef574da9 /Xmobar.hs | |
parent | ed885c39e52be7a81163fcdddd9fd00e30c6eb8a (diff) | |
download | xmobar-7064cb084ea05f13a54ec7cfb2956f5ade5458ba.tar.gz xmobar-7064cb084ea05f13a54ec7cfb2956f5ade5458ba.tar.bz2 |
The MVar is needed to avoid a race condition
As Spencer noted the checker thread may be throwing an exception
immediately, thus producing a race condition.
darcs-hash:20071011203029-d6583-64a79e4be3cf1ab97c7ba2ee36db08166c9003d4.gz
Diffstat (limited to 'Xmobar.hs')
-rw-r--r-- | Xmobar.hs | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -70,11 +70,12 @@ runX c d w f = runReaderT f (XConf d w c) -- | The event loop eventLoop :: Config -> [(Maybe ThreadId, TVar String)] -> Display -> Window -> IO () -eventLoop c v d w = block $ do +eventLoop c v d w = do + b <- newEmptyMVar tv <- atomically $ newTVar [] - t <- myThreadId - forkIO $ checker t tv "" - go tv + t <- forkIO (block $ do putMVar b (); go tv) + takeMVar b + checker t tv "" where -- interrupt the drawing thread every time a var is updated checker t tvar ov = do |