shared Variant[string]

Tobias Pankrath via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jan 28 04:32:28 PST 2015


On Wednesday, 28 January 2015 at 12:29:09 UTC, Fyodor Ustinov 
wrote:
> On Wednesday, 28 January 2015 at 11:27:53 UTC, Kagamin wrote:
>> Associative array doesn't support thread-safe operations, 
>> that's why they don't work on shared instance. You should use 
>> std.concurrency or implement low-level concurrency mechanism.
>
> If associative array does not support "share" attribute, this 
> code should not be compiled without any warning or error, I 
> think:
>
> shared string[string] t;
> void main() {
>     t["t"] = "bebebe";
> }
>
> But will.

In your case above, it's std.variant : Variant, which does not 
work when shared. You'll need to cast it and ensure yourself that 
no two threads access the same instance concurrently.

I don't know, if AA should/do work with shared.


More information about the Digitalmars-d-learn mailing list