On "A New Collections Framework for the Standard Library"

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Thu May 18 11:32:17 PDT 2017


On 05/18/2017 02:17 PM, Jack Stouffer wrote:
> On Thursday, 18 May 2017 at 15:18:00 UTC, Jack Stouffer wrote:
>> ...
>
> Also, shared allocators raise another problem entirely. Let's say for
> the sake of clarity that these future containers will use a separate
> range type.
>
> Let's say you have a container with five elements, and then you give a
> range of those elements to a function that caches the length somewhere
> because it's available (very common as ranges have never been expected
> to change before). What happens when you're iterating over the range and
> then another thread calls removeBack before the loop is completed? All
> sorts of functions in Phobos will blow up in interesting and different
> ways.

If two or more threads have access to a container, that would be shared. 
Many traditional containers aren't usable gainfully as shared, so we 
plan to implement a few specialized ones. Anyhow, for now you won't be 
able to use containers that are shared. -- Andrei


More information about the Digitalmars-d mailing list