Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Made externalMulti thread-safe.

  • Loading branch information...
commit 6c1695b896bafca07f6cf5f7bd6b4a1701352c0b 1 parent 5b2899a
@takano-akio takano-akio authored
View
7 FRP/Elerea/Clocked.hs
@@ -530,10 +530,9 @@ externalMulti :: IO (SignalGen (Signal [a]), a -> IO ()) -- ^ a generator for th
externalMulti = do
var <- newMVar []
return (SG $ \gpool _pool -> do
- let sig = S $ readMVar var
- update <- mkWeak sig (return (),takeMVar var >> putMVar var []) Nothing
- modifyIORef gpool (USig update:)
- return sig
+ ref <- newIORef (Ready undefined)
+ let sample = modifyMVar var $ \list -> memoise ref list >> return ([], list)
+ addSignal (const sample) (const (() <$ sample)) ref gpool
,\val -> do
vals <- takeMVar var
putMVar var (val:vals)
View
7 FRP/Elerea/Param.hs
@@ -434,10 +434,9 @@ externalMulti :: IO (SignalGen p (Signal [a]), a -> IO ()) -- ^ a generator for
externalMulti = do
var <- newMVar []
return (SG $ \pool _ -> do
- let sig = S $ readMVar var
- update <- mkWeak sig (return (),takeMVar var >> putMVar var []) Nothing
- modifyIORef pool (update:)
- return sig
+ ref <- newIORef (Ready undefined)
+ let sample = modifyMVar var $ \list -> memoise ref list >> return ([], list)
+ addSignal (const sample) (const (() <$ sample)) ref pool
,\val -> do vals <- takeMVar var
putMVar var (val:vals)
)
View
7 FRP/Elerea/Simple.hs
@@ -414,10 +414,9 @@ externalMulti :: IO (SignalGen (Signal [a]), a -> IO ()) -- ^ a generator for th
externalMulti = do
var <- newMVar []
return (SG $ \pool -> do
- let sig = S $ readMVar var
- update <- mkWeak sig (return (),takeMVar var >> putMVar var []) Nothing
- modifyIORef pool (update:)
- return sig
+ ref <- newIORef (Ready undefined)
+ let sample = modifyMVar var $ \list -> memoise ref list >> return ([], list)
+ addSignal (const sample) (const (() <$ sample)) ref pool
,\val -> do vals <- takeMVar var
putMVar var (val:vals)
)
Please sign in to comment.
Something went wrong with that request. Please try again.