Passing associative array to another thread
Jacob Carlborg
doob at me.com
Fri Sep 21 10:01:33 PDT 2012
On 2012-09-21 16:33, Martin Drasar wrote:
> Hi,
>
> I am using the std.concurrency module and I would like to send an
> associative array to another thread.
>
> If I try this:
>
> string[string] aa;
> someThread.send(aa);
>
> I get: Aliases to mutable thread-local data not allowed.
>
> And if I try to use this:
>
> immutable(string[string]) aa;
> someThread.send(aa);
>
> I get:
> /usr/include/d/dmd/phobos/std/variant.d(539): Error: *p is not mutable
>
> which is because the send() creates a Message struct that stores the
> data in a Variant.
>
> And now I am stuck, because I do not have any idea what to do. Any advice?
Perhaps declaring the associative array as "shared". An alternative
would be to serialize the aa, pass it to another thread, and deserialize
it. That would though create a copy.
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list