summaryrefslogtreecommitdiffhomepage
path: root/Plugins
diff options
context:
space:
mode:
authorJose A Ortega Ruiz <jao@gnu.org>2010-02-12 00:58:21 +0100
committerJose A Ortega Ruiz <jao@gnu.org>2010-02-12 00:58:21 +0100
commit2169c1b1dea4391366e07d18a3743748ff94fe9e (patch)
treeaf844d52c5fcfa67d1cad16307f55fc0023823fd /Plugins
parent581c3b42495d48960356ef1014bc41ffc82aec27 (diff)
downloadxmobar-2169c1b1dea4391366e07d18a3743748ff94fe9e.tar.gz
xmobar-2169c1b1dea4391366e07d18a3743748ff94fe9e.tar.bz2
Cosmetics
Ignore-this: eb0c478fb8547f3cd20ded3cd195b06c darcs-hash:20100211235821-748be-dee59b89551e86363cdd42f2de229ace35f5437b.gz
Diffstat (limited to 'Plugins')
-rw-r--r--Plugins/Monitors/Top.hs18
1 files changed, 8 insertions, 10 deletions
diff --git a/Plugins/Monitors/Top.hs b/Plugins/Monitors/Top.hs
index 14ccf1e..a0b3fb7 100644
--- a/Plugins/Monitors/Top.hs
+++ b/Plugins/Monitors/Top.hs
@@ -12,7 +12,7 @@
--
-----------------------------------------------------------------------------
-{-# LANGUAGE ForeignFunctionInterface #-}
+{-# LANGUAGE ForeignFunctionInterface, BangPatterns #-}
module Plugins.Monitors.Top (startTopCpu, topMemConfig, runTopMem) where
@@ -131,21 +131,19 @@ type TIVar = MVar Times
topTimeProcesses :: Int -> TIVar -> Float -> IO [Timeinfo]
topTimeProcesses n tivar lapse = do
- t0 <- readMVar tivar
- t1 <- timeinfos
- modifyMVar_ tivar (\_ -> return $! t1)
- let ts = M.elems $ combineTimeInfos t0 t1
- sts = take n $ sortBy cmp ts
- cmp (TI _ x) (TI _ y) = compare y x
- norm (TI nm t) = TI nm (100 * t / lapse)
- return $! map norm sts
+ modifyMVar tivar $ \t0 ->
+ timeinfos >>= (\(!t1) -> let ts = M.elems $ combineTimeInfos t0 t1
+ sts = take n $ sortBy cmp ts
+ cmp (TI _ x) (TI _ y) = compare y x
+ norm (TI nm t) = TI nm (100 * t / lapse)
+ in return $! (t1, map norm sts))
showTimeInfo :: Timeinfo -> Monitor [String]
showTimeInfo (TI n t) = showInfo n (showDigits 1 t) t
runTopCpu :: TIVar -> Float -> [String] -> Monitor String
runTopCpu tivar lapse _ = do
- ps <- io $ topTimeProcesses maxProc tivar lapse
+ ps <- io $! topTimeProcesses maxProc tivar lapse
pstr <- mapM showTimeInfo ps
parseTemplate $ concat pstr