Thread overview | ||||||
---|---|---|---|---|---|---|
|
April 12, 2014 Associative arrays, multithreading, Rebindable | ||||
---|---|---|---|---|
| ||||
If I want to pass a dynamic array from one thread to another, then I use immutable(T)[] and it is safe. But what if I need to pass an associative array? I suppose that the use of immutable(T)[U] is unsafe. Because one thread can delete the entry and this will have an impact also on the instance of the array in another thread. So I have to use immutable(T[U]). But the immutability of the entire array makes the array reference immutable too: immutable int[string] foo; foo = assumeUnique(other); // error For immutable classes we can use std.typecons.Rebindable: Rebindable!(immutable Foo) foo; foo = new immutable Foo; // fine But for immutable associative arrays we can't: Rebindable!(immutable int[string]) foo; // error foo = assumeUnique(other); Error: template instance std.typecons.Rebindable!(immutable(int[string])) does not match template declaration Rebindable(T) if (is(T == class) || is(T == interface) || isArray!T) Should Rebindable to support associative arrays? |
April 12, 2014 Re: Associative arrays, multithreading, Rebindable | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jack Applegame | Jack Applegame:
> Should Rebindable to support associative arrays?
I guess so. But how to implement it?
Bye,
bearophile
|
April 12, 2014 Re: Associative arrays, multithreading, Rebindable | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Saturday, 12 April 2014 at 09:18:12 UTC, bearophile wrote:
> Jack Applegame:
>
>> Should Rebindable to support associative arrays?
>
> I guess so. But how to implement it?
>
> Bye,
> bearophile
May be just like Rebindable for classes?
|
April 12, 2014 Re: Associative arrays, multithreading, Rebindable | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Saturday, 12 April 2014 at 09:18:12 UTC, bearophile wrote: > Jack Applegame: > >> Should Rebindable to support associative arrays? > > I guess so. But how to implement it? > > Bye, > bearophile Related: "Rebindable supports arrays (Which makes no sense)" https://issues.dlang.org/show_bug.cgi?id=12046 Quote: "It *might* make sense with associative arrays though... Not sure" |
Copyright © 1999-2021 by the D Language Foundation