[Haskell-cafe] Parallel executing of actions

Mitar mmitar at gmail.com
Sun Apr 15 15:56:02 EDT 2007


Hi!

On 4/15/07, Spencer Janssen <sjanssen at cse.unl.edu> wrote:
> This version will fork a new thread for each action:
>
> \begin{code}
> import Control.Concurrent
> import Control.Monad
>
> parSequence_ xs = do
>     m <- newEmptyMVar
>     mapM_ (\x -> forkIO x >> putMVar m ()) xs
>     replicateM_ (length xs) (takeMVar m)
>
> parMapM_ f xs = parSequence_ $ map f xs
> \end{code}

OpenGL bindings successfully crash. The functional calculations in f
should be done in parallel, but those few OpenGL actions should still
be done sequentially. I am attaching the code in question. It is a
simple voxel raycasting engine.

(Any suggestions on other memory/performance improvements are more
than welcome.)


Mitar
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Main.hs
Type: application/octet-stream
Size: 8087 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070415/5a1e35be/Main-0001.obj


More information about the Haskell-Cafe mailing list