Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: cobbpg/elerea
base: 9f6a867c21
...
head fork: cobbpg/elerea
compare: 5e2c77ffeb
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
Commits on Dec 21, 2011
@takano-akio takano-akio Ensured that signals created during an update phase get updated. a2333a7
Commits on Dec 22, 2011
@cobbpg Merge pull request #3 from takano-akio/new-signal-during-update
Signals created during an update phase don't get updated
5e2c77f
Showing with 50 additions and 14 deletions.
  1. +16 −4 FRP/Elerea/Clocked.hs
  2. +17 −5 FRP/Elerea/Param.hs
  3. +17 −5 FRP/Elerea/Simple.hs
View
20 FRP/Elerea/Clocked.hs
@@ -208,12 +208,24 @@ start (SG gen) = do
S sample <- gen pool pool
return $ do
res <- sample
- (ptrs,acts) <- unzip.catMaybes <$> (mapM getUpdate =<< readIORef pool)
- writeIORef pool ptrs
- mapM_ fst acts
- mapM_ snd acts
+ cleanup pool
return res
+cleanup :: IORef UpdatePool -> IO ()
+cleanup pool =
+ let
+ loop allPtrs final = do
+ (ptrs,acts) <- unzip.catMaybes <$> (mapM getUpdate =<< readIORef pool)
+ if null acts
+ then do
+ final
+ writeIORef pool allPtrs
+ else do
+ writeIORef pool []
+ mapM_ fst acts
+ loop (ptrs++allPtrs) (final >> mapM_ snd acts)
+ in loop [] (return ())
+
-- | Auxiliary function used by all the primitives that create a
-- mutable variable.
addSignal :: (a -> IO a) -- ^ sampling function
View
22 FRP/Elerea/Param.hs
@@ -145,15 +145,27 @@ start (SG gen) = do
(inp,sink) <- external undefined
S sample <- gen pool inp
return $ \param -> do
- let deref ptr = (fmap.fmap) ((,) ptr) (deRefWeak ptr)
sink param
res <- sample
- (ptrs,acts) <- unzip.catMaybes <$> (mapM deref =<< readIORef pool)
- writeIORef pool ptrs
- mapM_ fst acts
- mapM_ snd acts
+ cleanup pool
return res
+cleanup :: IORef UpdatePool -> IO ()
+cleanup pool =
+ let
+ deref ptr = (fmap.fmap) ((,) ptr) (deRefWeak ptr)
+ loop allPtrs final = do
+ (ptrs,acts) <- unzip.catMaybes <$> (mapM deref =<< readIORef pool)
+ if null acts
+ then do
+ final
+ writeIORef pool allPtrs
+ else do
+ writeIORef pool []
+ mapM_ fst acts
+ loop (ptrs++allPtrs) (final >> mapM_ snd acts)
+ in loop [] (return ())
+
-- | Auxiliary function used by all the primitives that create a
-- mutable variable.
addSignal :: (a -> IO a) -- ^ sampling function
View
22 FRP/Elerea/Simple.hs
@@ -137,14 +137,26 @@ start (SG gen) = do
pool <- newIORef []
S sample <- gen pool
return $ do
- let deref ptr = (fmap.fmap) ((,) ptr) (deRefWeak ptr)
res <- sample
- (ptrs,acts) <- unzip.catMaybes <$> (mapM deref =<< readIORef pool)
- writeIORef pool ptrs
- mapM_ fst acts
- mapM_ snd acts
+ cleanup pool
return res
+cleanup :: IORef UpdatePool -> IO ()
+cleanup pool =
+ let
+ deref ptr = (fmap.fmap) ((,) ptr) (deRefWeak ptr)
+ loop allPtrs final = do
+ (ptrs,acts) <- unzip.catMaybes <$> (mapM deref =<< readIORef pool)
+ if null acts
+ then do
+ final
+ writeIORef pool allPtrs
+ else do
+ writeIORef pool []
+ mapM_ fst acts
+ loop (ptrs++allPtrs) (final >> mapM_ snd acts)
+ in loop [] (return ())
+
-- | Auxiliary function used by all the primitives that create a
-- mutable variable.
addSignal :: (a -> IO a) -- ^ sampling function

No commit comments for this range

Something went wrong with that request. Please try again.