Sharing in D

dsimcha dsimcha at yahoo.com
Mon Aug 11 12:10:51 PDT 2008


One thing that recently popped into my mind about the shared/unshared discussion:
 What about arrays, etc that are manipulated by multiple threads, but in such a
way that each thread is guaranteed not to touch the same elements as any other
thread, and to never reallocate the array?  This is something I actually do, for
such things as filling in large matrices.  If I understand this proposal
correctly, if the array is unshared, multiple threads can't touch it.  If it is
shared, the compiler will automatically make it synchronized.  In this case, the
synchronization overhead might be large and unnecessary.  If I have each thread
write to separate, unshared data structures and merge them together later, then
I'm adding needless complexity to my code.



More information about the Digitalmars-d mailing list