Thread overview |
---|
August 04, 2016 Pass Tid[string] to another thread (by send) | ||||
---|---|---|---|---|
| ||||
Hi! I'm trying to make threads communicate by sending an immutable address book to each thread. Code: Tid[string] addressBook; addressBook["Some"] = sdfsdf; addressBook["Input"] = sdfsdf; auto sharedAddressBook = cast(immutable(Tid[string]))(addressBook); send(tid, sharedAddressBook); // <- error Output log: C:\D\dmd2\windows\bin\..\..\src\phobos\std\variant.d(439): Error: cannot modify immutable expression (*zis)[args[1].get()] C:\D\dmd2\windows\bin\..\..\src\phobos\std\variant.d(632): Error: template instance std.variant.VariantN!20LU.VariantN.handler!(immutable(int[immutable(string)])) error instantiating C:\D\dmd2\windows\bin\..\..\src\phobos\std\variant.d(548): instantiated from here: opAssign!(immutable(int[immutable(string)])) C:\D\dmd2\windows\bin\..\..\src\phobos\std\concurrency.d(117): instantiated from here: __ctor!(immutable(int[immutable(string)])) C:\D\dmd2\windows\bin\..\..\src\phobos\std\concurrency.d(639): instantiated from here: __ctor!(immutable(int[immutable(string)])) C:\D\dmd2\windows\bin\..\..\src\phobos\std\concurrency.d(629): ... (1 instantiations, -v to show) ... C:\D\dmd2\windows\bin\..\..\src\phobos\std\concurrency.d(605): instantiated from here: _send!(immutable(int[immutable(string)])) src\aelia\aelia.d(42): instantiated from here: send!(immutable(int[immutable(string)])) Building build\x64\Debug\AeliaD.exe failed! variant.d: ... else static if (isAssociativeArray!(A)) { (*zis)[args[1].get!(typeof(A.init.keys[0]))] // <- line 439 = args[0].get!(typeof(A.init.values[0])); break; } ... What am I doing wrong? Is there a proper way to pass an associative array to another thread? I also found a thread on the forum http://forum.dlang.org/post/mailman.209.1348312788.5162.digitalmars-d-learn@puremagic.com that saying it is a bug in Variant, but that bug was fixed already. Have I found a new one? %) Sincerely, Alexey |
August 05, 2016 Re: Pass Tid[string] to another thread (by send) | ||||
---|---|---|---|---|
| ||||
Posted in reply to TencoDK | Bug 6585 is not fixed. Variant wasn't written for shared and immutable types. As a workaround wrap the array in a class. |
August 05, 2016 Re: Pass Tid[string] to another thread (by send) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Friday, 5 August 2016 at 13:14:41 UTC, Kagamin wrote: > Bug 6585 is not fixed. Variant wasn't written for shared and immutable types. As a workaround wrap the array in a class. Thanks! It worked. Though it's strange that >Variant wasn't written for shared and immutable types because, for instance, in TDPL it has been used in multithreading context. |
Copyright © 1999-2021 by the D Language Foundation