summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-15 19:53:53 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-15 19:53:53 +0100
commit4efee1638abb29b0fac40b9010585ed243cf4bfa (patch)
tree1a466eb52a297a4a23ce63d201be65cebee4de60
parent6fadf3e159c371f00ccd6261a9f01fc81fad375e (diff)
downloadxmobar-4efee1638abb29b0fac40b9010585ed243cf4bfa.tar.gz
xmobar-4efee1638abb29b0fac40b9010585ed243cf4bfa.tar.bz2
Irrelevant cleansing
... and, please, disregard my stupid comment on zero lapses after sleep (i just needed to sleep myself): i'm afraid the bug's still there.
-rw-r--r--Plugins/Monitors/Top.hs19
1 files changed, 10 insertions, 9 deletions
diff --git a/Plugins/Monitors/Top.hs b/Plugins/Monitors/Top.hs
index 7246183..25d339a 100644
--- a/Plugins/Monitors/Top.hs
+++ b/Plugins/Monitors/Top.hs
@@ -19,15 +19,16 @@ module Plugins.Monitors.Top (startTop, topMemConfig, runTopMem) where
import Plugins.Monitors.Common
import Control.Exception (SomeException, handle)
-import System.Directory
-import System.FilePath
-import System.IO
-import System.Posix.Unistd (getSysVar, SysVar(ClockTick))
-import Foreign.C.Types
+import Data.IORef (IORef, newIORef, atomicModifyIORef)
import Data.List (sortBy)
import Data.Ord (comparing)
-import Data.IORef
-import Data.Time.Clock
+import Data.Time.Clock (UTCTime, getCurrentTime, diffUTCTime)
+import System.Directory (getDirectoryContents)
+import System.FilePath ((</>))
+import System.IO (IOMode(ReadMode), hGetLine, withFile)
+import System.Posix.Unistd (SysVar(ClockTick), getSysVar)
+
+import Foreign.C.Types
import Data.IntMap (IntMap)
import qualified Data.IntMap as M
@@ -133,8 +134,8 @@ topProcesses tref scale = do
c1 <- getCurrentTime
atomicModifyIORef tref $ \(t0, c0) ->
let scx = realToFrac (diffUTCTime c1 c0) * scale / 100
- -- c0 and c1 can be equal, for instance, if we come back from sleep
- !scx' = if scx > 0 then scx else (scale / 100)
+ -- c0 and c1 can be equal, for instance, if we tweak the clock
+ !scx' = if scx > 0 then scx else scale / 100
ts = M.elems $ combineTimeInfos t0 t1
nts = map (\(nm, t) -> (nm, min 100 (t / scx'))) ts
in ((t1, c1), (len, sortTop nts, sortTop mis))