[Haskell-cafe] Parallel executing of actions

Sebastian Sylvan sebastian.sylvan at gmail.com
Tue Apr 17 13:56:14 EDT 2007


On 4/16/07, Mitar <mmitar at gmail.com> wrote:
>
> Hi!
>
> On 4/16/07, Bertram Felgenhauer <bertram.felgenhauer at googlemail.com>
> wrote:
> > > Since all the threads block on a single MVar how do they run in
> > > parallel?
> >
> > The idea is that before the threads block on the MVar, they run their
> > action x to completion.
>
> The rendering crashes. I will have to precompute the values in threads
> someway and then sequentially draw it? Any suggestion how to do that?
>
>
Rendering into the same rendering context from multiple threads at the same
time is a baaad idea.

I would suggest chunking up your work (assuming that calculating your colour
is indeed a significant amount of work) in tiles or something, then fork off
a thread for each of them, sticking the final colours in a Chan. Then you
have another thread just pick tiles off the Chan and copy the results to the
frame buffer.

-- 
Sebastian Sylvan
+44(0)7857-300802
UIN: 44640862
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070417/43fcdbc5/attachment.htm


More information about the Haskell-Cafe mailing list