summaryrefslogtreecommitdiff
path: root/trivmix
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2018-05-15 21:24:01 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2018-05-15 21:24:01 +0200
commit67ecbcfc95a8d2c214fac546fc7d2e83d4c4fc10 (patch)
treec012ecc71f2995aae3bb4f15c144c563e7fa8aec /trivmix
parent879e0c7218298349b9c92e9d3362830c371ec78e (diff)
downloadtrivmix-67ecbcfc95a8d2c214fac546fc7d2e83d4c4fc10.tar
trivmix-67ecbcfc95a8d2c214fac546fc7d2e83d4c4fc10.tar.gz
trivmix-67ecbcfc95a8d2c214fac546fc7d2e83d4c4fc10.tar.bz2
trivmix-67ecbcfc95a8d2c214fac546fc7d2e83d4c4fc10.tar.xz
trivmix-67ecbcfc95a8d2c214fac546fc7d2e83d4c4fc10.zip
Don't update level when unneccessary
Diffstat (limited to 'trivmix')
-rw-r--r--trivmix/Trivmix.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/trivmix/Trivmix.hs b/trivmix/Trivmix.hs
index 5cddf6f..7c18965 100644
--- a/trivmix/Trivmix.hs
+++ b/trivmix/Trivmix.hs
@@ -194,7 +194,9 @@ trivmix Options{..} = do
194 mulBalance (bToScientific -> b) x = either error id $ asScientific (*) (Lin . either error id $ refine b) x 194 mulBalance (bToScientific -> b) x = either error id $ asScientific (*) (Lin . either error id $ refine b) x
195 newLevel <- mulBalance <$> readMVar balance <*> readMVar level 195 newLevel <- mulBalance <$> readMVar balance <*> readMVar level
196 currentLevel <- (\(CFloat f) -> Lin . either error id . refine $ realToFrac f) <$> readMVar level' 196 currentLevel <- (\(CFloat f) -> Lin . either error id . refine $ realToFrac f) <$> readMVar level'
197 mapM_ (\x -> (swapMVar level' $! toRealFloat . unrefine . toLin $ linInt' x currentLevel newLevel) >> threadDelay delay) (takeWhile (<= 1) $ iterate (+ recip frames) 0) 197 case compare currentLevel newLevel of
198 EQ -> threadDelay . round $ interval * 1e6
199 _ -> mapM_ (\x -> (swapMVar level' $! toRealFloat . unrefine . toLin $ linInt' x currentLevel newLevel) >> threadDelay delay) (takeWhile (<= 1) $ iterate (+ recip frames) 0)
198 notifyReady 200 notifyReady
199 forever $ threadDelay (round $ watchdogInterval * 1e6) >> notifyWatchdog 201 forever $ threadDelay (round $ watchdogInterval * 1e6) >> notifyWatchdog
200 202