[Issue 8077] Regression (2.058): .reserve does not work for shared arrays

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed May 16 11:05:15 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8077


Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla at digitalmars.com
         Resolution|                            |INVALID


--- Comment #1 from Walter Bright <bugzilla at digitalmars.com> 2012-05-16 11:06:45 PDT ---
I'm going to argue that although the code compiled in 2.057, it was not correct
and had latent concurrency bugs. The problems are:

1. being shared doesn't mean that assignments to an array are atomic

2. there is no obvious place to put a lock around updating a shared resource
like a shared array

3. locks can be very, very slow. Shared does not mean "automatically insert
locks"

Therefore, I'm going to mark this as invalid.

In essence, you (the programmer) has to decide how to manage the memory is to
be controlled by a shared array. You can allocate an array as thread local,
then cast it to shared as a last step (probably the best approach). If the
array is already shared, you'll have to protect the resize with a lock that
fits in with your data structure.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list