diff options
author | Andrea Rossato <andrea.rossato@ing.unitn.it> | 2007-06-27 11:44:46 +0200 |
---|---|---|
committer | Andrea Rossato <andrea.rossato@ing.unitn.it> | 2007-06-27 11:44:46 +0200 |
commit | 9e5978006348cc78fd5aafbc010cb828b11c0503 (patch) | |
tree | 4b388709746a30e8fde6c68f4974c79998a9e45d | |
parent | 128e55e5a641d0e3ce4780f647c60d0e6756b1cc (diff) | |
download | xmobar-9e5978006348cc78fd5aafbc010cb828b11c0503.tar.gz xmobar-9e5978006348cc78fd5aafbc010cb828b11c0503.tar.bz2 |
possibility to delay a thread for more than (maxBound :: Int) microseconds
darcs-hash:20070627094446-d6583-a6eaac63d4cada455b5751010338f324508c87fb.gz
-rw-r--r-- | XMobar.hs | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -261,8 +261,12 @@ initColor dpy c = (color_pixel . fst) `liftM` allocNamedColor dpy colormap c io :: IO a -> Xbar a io = liftIO +-- | work arount the the Int max bound: since threadDelay takes an Int, it +-- is not possible to set a thread delay grater than about 45 minutes. +-- With a little recursion we solve the problem. tenthSeconds :: Int -> IO () -tenthSeconds s = - threadDelay n - where n | (maxBound :: Int) `div` 100000 <= s = (maxBound :: Int) - | otherwise = s * 100000 +tenthSeconds s | s >= x = do threadDelay y + tenthSeconds (x - s) + | otherwise = threadDelay (s * 100000) + where y = (maxBound :: Int) + x = y `div` 100000 |