January 29, 2015 Re: shared Variant[string] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Fyodor Ustinov | 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.
string is a shorthand for "immutable char" - and immutables are shared by default. No thread can modify them, so default shared is safe for them.
|
Copyright © 1999-2021 by the D Language Foundation