From a7991c21030b8097db58a6c6ca67a2ce3bec7b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20B=C3=A4renz?= Date: Wed, 4 Oct 2023 17:49:36 +0200 Subject: [PATCH] Fix gloss event clock again --- rhine-gloss/src/FRP/Rhine/Gloss/IO.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rhine-gloss/src/FRP/Rhine/Gloss/IO.hs b/rhine-gloss/src/FRP/Rhine/Gloss/IO.hs index 437db9d9..6c617d02 100644 --- a/rhine-gloss/src/FRP/Rhine/Gloss/IO.hs +++ b/rhine-gloss/src/FRP/Rhine/Gloss/IO.hs @@ -24,6 +24,7 @@ where -- base import Control.Concurrent +import Control.Monad (when) import Data.Functor (void) import Data.IORef @@ -142,9 +143,8 @@ launchGlossThread GlossSettings {..} = do simStep diffTime vars@GlossEnv {timeVar, timeRef} = do time <- readIORef timeRef let !time' = time + diffTime - liftIO $ print time' - void $ tryPutMVar timeVar time' - writeIORef timeRef time' + timeUpdate <- tryPutMVar timeVar time' + when timeUpdate $ writeIORef timeRef time' return vars void $ liftIO $ forkIO $ playIO display backgroundColor stepsPerSecond vars getPic handleEvent simStep return vars