How to pack types with variables in one message to send it to another thread? [tuple]
MarisaLovesUsAll via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Sep 7 09:00:03 PDT 2014
> No need.
Message has additional arguments.
Btw, thanks for help! I found a solution.
struct Message
{
uint id;
string command;
Variant[] args;
this(T...)(uint id, string command, T args)
{
this.id = id;
this.command = command;
this.args = variantArray(args);
}
};
send(tid, cast(immutable Message) Message(id, "Sprite", "load",
filename));
receive((immutable Message receivedMsg)
{
Message msg = cast(Message) receivedMsg;
writeln(msg.args[1].get!uint);
});
Cast to immutable and back to mutable looks like crutch, but I
don't know what to do with std.concurrency restrictions.
More information about the Digitalmars-d-learn
mailing list