Passing associative array to another thread

Martin Drasar drasar at ics.muni.cz
Sat Sep 22 02:24:45 PDT 2012


On 21.9.2012 19:01, Jacob Carlborg wrote:
> 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.

Hi Jacob,

thanks for the hint. Making it shared sounds a bit fishy to me. My
intention is to pass some read only data, that are in fact thread local
and there is no real need to make them shared.

The (de)serialization is possible but the overhead seems a bit
pointless. I will alter the code to use something else than AAs if there
is no other way.

The data I am trying to pass is in fact just name-value pairs. I have
tried to use Tuples, but I have hit another batch of problems. One was
related to issue #5783, but another made me really scratch my head...

This compiles ok:
struct S { Tuple!int i; }

This does not:
struct S {
  Tuple!int i;
  SysTime   t;
}

Error: function
std.typecons.Tuple!(int).Tuple.opEquals!(const(Tuple!(int))).opEquals
(const(Tuple!(int)) rhs) is not callable using argument types
(const(Tuple!(int))) const

This looks a lot like the #5783, but I don't understand, why it only
shows up with the SysTime in place...

Martin


More information about the Digitalmars-d-learn mailing list