www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How do I send a message to a struct member function?

reply Enjoys Math <enjoysmath gmail.com> writes:
I have a series of structs each of which needs to spawn a worker 
thread on initialization.  There seems to be no way to send a 
message back to the struct for instance to cause a member 
function call on /that/ structs data.

Please advise me.
Aug 25
parent reply drug <drug2004 bk.ru> writes:
26.08.2017 09:49, Enjoys Math пишет:
 
 I have a series of structs each of which needs to spawn a worker thread 
 on initialization.  There seems to be no way to send a message back to 
 the struct for instance to cause a member function call on /that/ 
 structs data.
 
 Please advise me.
If it is appropriate for you the better way would be to send /that/ structs to the corresponding worker thread and then it can call any method. Another way is you can during worker thread spawning pass thread id and then pass messages back to parent thread.
Aug 26
parent Enjoys Math <enjoysmath gmail.com> writes:
On Saturday, 26 August 2017 at 10:05:31 UTC, drug wrote:
 26.08.2017 09:49, Enjoys Math пишет:
 
 I have a series of structs each of which needs to spawn a 
 worker thread on initialization.  There seems to be no way to 
 send a message back to the struct for instance to cause a 
 member function call on /that/ structs data.
 
 Please advise me.
If it is appropriate for you the better way would be to send /that/ structs to the corresponding worker thread and then it can call any method. Another way is you can during worker thread spawning pass thread id and then pass messages back to parent thread.
I can't do the second approach because the parent thread creates many instances of the struct, each of which need a call back to a method. How do I do the first method (in code) because I've tried 20 different ways already.
Aug 26