@@ -11,6 +11,7 @@ import Reflex.Dom.PerformEvent.Class
11import Reflex.Dom.PostBuild.Class
11import Reflex.Dom.PostBuild.Class
13import Control.Concurrent
13import Control.Concurrent
14+import qualified Control.Concurrent.Thread.Delay as Concurrent
14import Control.Monad
15import Control.Monad
15import Control.Monad.Fix
16import Control.Monad.Fix
16import Control.Monad.IO.Class
17import Control.Monad.IO.Class
@@ -51,7 +52,7 @@ tickLossyFrom dt t0 e = do
51 return result
52 return result
52 where callAtNextInterval _ cb = void $ liftIO $ forkIO $ do
53 where callAtNextInterval _ cb = void $ liftIO $ forkIO $ do
53 tick <- getCurrentTick dt t0
54 tick <- getCurrentTick dt t0
54− threadDelay $ ceiling $ (dt - _tickInfo_alreadyElapsed tick) * 1000000
55+ Concurrent.delay $ ceiling $ (dt - _tickInfo_alreadyElapsed tick) * 1000000
57clockLossy :: (MonadIO m, PerformEvent t m, TriggerEvent t m, MonadIO (Performable m), PostBuild t m, MonadHold t m, MonadFix m) => NominalDiffTime -> UTCTime -> m (Dynamic t TickInfo)
58clockLossy :: (MonadIO m, PerformEvent t m, TriggerEvent t m, MonadIO (Performable m), PostBuild t m, MonadHold t m, MonadFix m) => NominalDiffTime -> UTCTime -> m (Dynamic t TickInfo)
@@ -70,7 +71,7 @@ getCurrentTick dt t0 = do
70-- | Delay an Event's occurrences by a given amount in seconds.
71-- | Delay an Event's occurrences by a given amount in seconds.
71delay :: (PerformEvent t m, TriggerEvent t m, MonadIO (Performable m)) => NominalDiffTime -> Event t a -> m (Event t a)
72delay :: (PerformEvent t m, TriggerEvent t m, MonadIO (Performable m)) => NominalDiffTime -> Event t a -> m (Event t a)
72delay dt e = performEventAsync $ ffor e $ \a cb -> liftIO $ void $ forkIO $ do
73delay dt e = performEventAsync $ ffor e $ \a cb -> liftIO $ void $ forkIO $ do
73− threadDelay $ ceiling $ dt * 1000000
74+ Concurrent.delay $ ceiling $ dt * 1000000
76-- | Send events with Poisson timing with the given basis and rate
77-- | Send events with Poisson timing with the given basis and rate
@@ -157,7 +158,7 @@ inhomogeneousPoissonFrom rnd rate maxRate t0 e = do
157 alreadyElapsed = diffUTCTime t tTargetLast
158 alreadyElapsed = diffUTCTime t tTargetLast
158 tTarget = addUTCTime dt tTargetLast
159 tTarget = addUTCTime dt tTargetLast
159 thisDelay = realToFrac $ diffUTCTime tTarget t :: Double
160 thisDelay = realToFrac $ diffUTCTime tTarget t :: Double
160− threadDelay $ ceiling $ thisDelay * 1000000
161+ Concurrent.delay $ ceiling $ thisDelay * 1000000
161 _ <- cb (TickInfo t nEvents alreadyElapsed, p)
162 _ <- cb (TickInfo t nEvents alreadyElapsed, p)
162 go tTarget nextGen' cb nEvents
163 go tTarget nextGen' cb nEvents