Attempt to improve perfomance

This commit is contained in:
2022-08-25 09:52:12 +01:00
parent 6973663055
commit 920bfdbc8e
18 changed files with 60 additions and 311 deletions
+8 -6
View File
@@ -1,22 +1,24 @@
module Dodge.Concurrent where
import Dodge.Data.Universe
--import qualified Data.Set as S
import Control.Lens
import Dodge.Data.Universe
--import Control.Concurrent
--import SDL.Input.Keyboard.Codes
conEffects :: Universe -> Maybe (Universe -> Universe,IO (Universe -> Maybe Universe))
conEffects :: Universe -> ConcurrentEffect Universe
conEffects u = case u ^. uvConcEffects of
NewConcEffect {_ceFunction = eff} -> Just eff
_ -> Nothing
NewConcEffect{_ceFunction = eff} -> eff
_ -> NoConcurrentEffect
tryConcEffect :: Bool -> String -> IO (Universe -> Maybe Universe) -> Universe -> Universe
tryConcEffect bl str eff u = case u ^. uvConcEffects of
NoConcEffect -> u & uvConcEffects .~ NewConcEffect (setstr, clearConcEff eff) str bl
NoConcEffect -> u & uvConcEffects .~ NewConcEffect (ConcurrentEffect setstr (clearConcEff eff)) str bl
_ -> u
where
setstr | bl = uvConcEffects .~ BlockingConcEffect str
setstr
| bl = uvConcEffects .~ BlockingConcEffect str
| otherwise = uvConcEffects .~ BackgroundConcEffect str
clearConcEff :: IO (Universe -> Maybe Universe) -> IO (Universe -> Maybe Universe)