|Think about Loose Coupling|
Access to $self in a thread?by Codeman_Rhodes (Novice)
|on Sep 12, 2013 at 13:24 UTC||Need Help??|
Codeman_Rhodes has asked for the
wisdom of the Perl Monks concerning the following question:
I have a problem with some perl code I need to write for sending DMX data to an Open-Lightning-Architecture-Daemon (that's for lightning of stages and so on).
I have written a class which connects to the "olad" and starts a background thread which sends regulary DMX-data to the daemon. For changing the DMX-data I have accessors defined.
My problem is, that the thread does no see changes inside the DMX-data. I started the thread with a reference to $self as an argument and inside the thread I use the argument as $super. I can dump all data from $super but if something outside the thread changes the data, this is not seen inside the thread. It seems that the thread has got a copy of %self instead of a reference.
I also tried to use shared(%self) - but I don't know how to access this data.
Here is my (test) code (TTTT.pm) withoud shared()-tests:
I tried to use the "set"-function and I tried to change the universe - the main program shows the changes, the thread does not.
What I am doing wrong?