[Haskell-cafe] Re: Parallel combinator, performance advice
haskell at list.mightyreason.com
Tue Apr 7 07:04:08 EDT 2009
You create one MVar for each task in order to ensure all the tasks are done.
This is pretty heavyweight.
You could create a single Control.Concurrent.QSemN to count the completed tasks,
starting with 0.
Each task is followed by signalQSemN with a value of 1. (I would use "finally").
As parallel_ launches the tasks it can count their number, then it would call
waitQSemN for that quantity to have finished.
More information about the Haskell-Cafe