[Haskell-cafe] Gloss and relatively expensive computations

Artyom Kazak artyom.kazak at gmail.com
Fri Dec 28 01:56:44 CET 2012


You could create a new thread which would be 'forever' executing your
extensive computation and updating some IOVar accordingly. The drawing
function would do nothing except reading that IOVar and displaying its
contents. Since drawing is cheap, this can be done at any reasonable rate.
28.12.2012 3:22 пользователь "Daniel Díaz Casanueva" <dhelta.diaz at gmail.com>
написал:

> Hello cafe!
>
> I'm having some performance issues trying to use gloss to make animations
> where each "model" step is relatively time expensive. I'm using the
> IO.Simulate module because my step function needs to do an IO operation
> which takes around 1 second (it may vary).
>
> I will try to give some details.
>
> I have the step function:
>
> step :: Model -> IO Model
> step m = do
>  ...
>  p <- slowOperation
>  ...
>  return newModel
>
> The rest of the program is small and simple. The drawing function (Model
> -> IO Picture -- it is pure though) is as quick as simple. However, the
> program get stuck after the first iteration.
>
> In the other hand, I am using the animateIO function which ask me for an
> Int value to set up "the number of simulation steps to take for each second
> of real time". But I'm more interested in the animation waiting for the
> simulation step to end. Does it make sense?
>
> I would be really thankful with any pointer here.
>
> Thanks in advance,
> Daniel Díaz.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20121228/ad5a62c0/attachment.htm>


More information about the Haskell-Cafe mailing list