
3 Dec
2007
3 Dec
'07
8:10 a.m.
Brad Clow wrote:
On Nov 28, 2007 11:30 AM, Matthew Brecknell
wrote: Even with threads, results are evaluated only when they are needed (or when forced by a strictness annotation). So the thread that needs a result (or forces it) first will be the one to evaluate it.
So does GHC implement some sychronisation given that a mutation is occuring under the covers, ie. the thunk is being replaced by the result?
Yes, see http://haskell.org/~simonmar/bib/multiproc05_abstract.html we use lock-free synchronisation, with a slight possibility that two threads might evaluate the same thunk. But since they'll produce the same result, nothing goes wrong. Cheers, Simon