Pointer across threads
Chris via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Nov 4 04:47:09 PST 2014
The following
struct DATA {
short* data;
size_t len;
}
// data and len are provided by a C function
// ...
auto data = mymodule.getSpeechData();
// cast to immutable, because of concurrency
immutable short* tmp = cast(immutable)(data.data);
auto proc = spawn(&processData, thisTid);
send(processData, tmp, data.len);
However, processData never receives "tmp". Is this because tmp
and data.data are still pointing to the same address? If this is
the case, why doesn't the compiler warn me? Or is it something
else (pointer not visible across threads?).
Is there a work around? (I wanted to avoid having to convert
short* to short[] and .idup it.)
More information about the Digitalmars-d-learn
mailing list