[grapefruit] Deadlock when sampling Continuous signals.

Roman Cheplyaka roma at ro-che.info
Tue Jul 14 05:23:19 EDT 2009


* Neal Alexander <relapse.dev at gmx.com> [2009-07-14 04:54:33-0400]
> 
> 
>    No, it deadlocks on this machine still. What version/os/ghc are you
>    using?
> 
>    And, the posted code diddnt compile because i tweaked a few things in
>    the email for whatever braindamaged reason =p.

What exactly are you observing?
If you use hackage version, try upgrading to darcs -- it might be an
issue solved in

Sun Apr  5 22:46:59 EEST 2009  Roman Cheplyaka <roma at ro-che.info>
  * Replace readMVar with takeMVar to avoid indefinite thread blocking

If it doesn't help, it might be a Windows issue.

I'm using ghc 6.10.2 under i386 Linux.

>      ----- Original Message -----
> 
>      From: Roman Cheplyaka
> 
>      Sent: 07/14/09 12:06 am
> 
>      To: Discussion about the Grapefruit FRP library
> 
>      Subject: Re: [grapefruit] Deadlock when sampling Continuous signals.
> 
> 
>      * Neal Alexander [2009-07-13 22:09:38-0400]
>      >
>      >
>      > (Using GHC 6.10.3 on windows7 and grapefruit-frp-0.0.0.)
>      >
>      > Most likely I'm doing something wrong, but its hard to find
>      examples
>      > dealing strictly with grapefruit-FRP (without grapefruit GUI).
>      >
>      > The intent is that the whole thing should boil down to: print
>      (0,0)
>      >
>      > -----------------
>      >
>      > circuit (sinkR,posR) = proc () -> do
>      > pos <- playerPos posR -< ()
>      > frameEvent <- framePassed sinkR -< ()
>      > display -< (frameEvent #> pos)
>      >
>      > returnA -< ()
>      >
>      > main = do
>      > a <- newIORef (return ())
>      > b <- newIORef (0,0)
>      >
>      > create (circuit (a,b)) ()
>      >
>      > frameEventSink <- readIORef a
>      >
>      > frameEVentSink () -- deadlocks here
>      >
>      > -------------------
>      >
>      > display :: Show val => forall era. Circuit era (DSignal era val)
>      ()
>      > display = consume $ consumer (print)
>      > playerPos :: IORef (Int,Int) -> forall era. Circuit era ()
>      (CSignal era
>      > (Int,Int))
>      > playerPos r = produce $ C.producer $ readIORef r
>      > framePassed ref = produce (D.producer event)
>      > where
>      > event :: (() -> IO ()) -> Setup
>      > event f = setup $ do
>      > writeIORef ref f
>      > return (return ())
>      This code just doesn't compile. If you make it compile, it prints
>      (0,0)
>      without any problem. And please, next time you send the code at
>      least
>      include all necessary imports (and even better, make sure the code
>      compiles).
>      --- y.hs 2009-07-14 10:00:03.000000000 +0300
>      +++ x.hs 2009-07-14 09:58:10.000000000 +0300
>      @@ -1,3 +1,13 @@
>      +{-# LANGUAGE Arrows, RankNTypes #-}
>      +import FRP.Grapefruit.Circuit
>      +import FRP.Grapefruit.Signal
>      +import FRP.Grapefruit.Setup
>      +import FRP.Grapefruit.Signal.Discrete as D
>      +import FRP.Grapefruit.Signal.Continuous as C
>      +import Data.IORef
>      +import Control.Arrow
>      +circuit
>      + :: (IORef (() -> IO ()), IORef (Int, Int)) -> Circuit era () ()
>      circuit (sinkR,posR) = proc () -> do
>      pos <- playerPos posR -< ()
>      frameEvent <- framePassed sinkR -< ()
>      @@ -7,7 +17,7 @@
>      main = do
>      - a <- newIORef (return ())
>      + a <- newIORef (const $ return ())
>      b <- newIORef (0,0)
>      @@ -16,8 +26,7 @@
>      frameEventSink <- readIORef a
>      - frameEVentSink () -- deadlocks here
>      -
>      + frameEventSink () -- deadlocks here
>      -------------------
>      --
>      Roman I. Cheplyaka :: http://ro-che.info/
>      "Don't let school get in the way of your education." - Mark Twain
>      _______________________________________________
>      Grapefruit mailing list
>      Grapefruit at projects.haskell.org
>      http://projects.haskell.org/cgi-bin/mailman/listinfo/grapefruit


-- 
Roman I. Cheplyaka :: http://ro-che.info/
"Don't let school get in the way of your education." - Mark Twain



More information about the Grapefruit mailing list