Re: How to pack types with variables in one message to send it to another thread? [tuple]

2014-09-07 Thread MarisaLovesUsAll via Digitalmars-d-learn
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

Re: How to pack types with variables in one message to send it to another thread? [tuple]

2014-09-07 Thread Philippe Sigaud via Digitalmars-d-learn
You can also create new types: struct UseSprite { string s;} struct UseAnimation { string s;} >> It's not a class instance, it's a class type. Something like >> `cast(Sprite) null` in parameters. It can be replaced by string >> "Sprite", but in this case I can't use receive() as it is. E.g. >> >

Re: How to pack types with variables in one message to send it to another thread? [tuple]

2014-09-07 Thread Rikki Cattermole via Digitalmars-d-learn
On 8/09/2014 12:39 a.m., MarisaLovesUsAll wrote: Thanks for reply. Strings are immutable so thats ok. A class instance that isn't immutable isn't. It's not a class instance, it's a class type. Something like `cast(Sprite) null` in parameters. It can be replaced by string "Sprite", but in this

Re: How to pack types with variables in one message to send it to another thread? [tuple]

2014-09-07 Thread MarisaLovesUsAll via Digitalmars-d-learn
Thanks for reply. Strings are immutable so thats ok. A class instance that isn't immutable isn't. It's not a class instance, it's a class type. Something like `cast(Sprite) null` in parameters. It can be replaced by string "Sprite", but in this case I can't use receive() as it is. E.g. send

Re: How to pack types with variables in one message to send it to another thread? [tuple]

2014-09-07 Thread hane via Digitalmars-d-learn
On Sunday, 7 September 2014 at 10:42:37 UTC, MarisaLovesUsAll wrote: Hi! I'm trying to make my program multithreaded, and I was stuck at messaging between threads. I need to pack types and variables into one message. Will I use Tuples or something? e.g. class Sprite {}; send(tid, Sprite, "c

Re: How to pack types with variables in one message to send it to another thread? [tuple]

2014-09-07 Thread Rikki Cattermole via Digitalmars-d-learn
On 7/09/2014 10:42 p.m., MarisaLovesUsAll wrote: Hi! I'm trying to make my program multithreaded, and I was stuck at messaging between threads. I need to pack types and variables into one message. Will I use Tuples or something? e.g. class Sprite {}; send(tid, Sprite, "create", myInt); Don't

How to pack types with variables in one message to send it to another thread? [tuple]

2014-09-07 Thread MarisaLovesUsAll via Digitalmars-d-learn
Hi! I'm trying to make my program multithreaded, and I was stuck at messaging between threads. I need to pack types and variables into one message. Will I use Tuples or something? e.g. class Sprite {}; send(tid, Sprite, "create", myInt); Also I don't understand how to use