how to handle shared arrays?

maarten van damme maartenvd1994 at gmail.com
Thu Jun 21 12:00:32 PDT 2012


I want to have two threads. One parses some content ever half hour and
the other continuously parses commands passed from the first thread.
When the second thread finished something it should send the results
back to the first thread who'll present it to the user.
The messages the second thread needs to send back is under the form of
an array of a struct.

Right now I'm trying something like this:
			shared (T[]) mods=cast(shared (T[]))modifications.dup;
			send(tid, mods);

This gives me a rather odd-looking errormessage:
C:\D\dmd2\windows\bin\..\..\src\phobos\std\variant.d(528): Error: function core.
stdc.string.memcpy (void* s1, const(void*) s2, uint n) is not callable using arg
ument types (ubyte[20u]*,shared(T[])*,uint)
C:\D\dmd2\windows\bin\..\..\src\phobos\std\variant.d(528): Error: cannot implici
tly convert expression (& rhs) of type shared(T[])* to const(
void*)

How should I handle arrays that I will need to send back to another thread?
Excuse me for all those questions, I'm really having a hard time
grasping the D threading model.


More information about the Digitalmars-d-learn mailing list