in reply to Re^11: does threads (still) memleak?
in thread does threads (still) memleak?
Because I stripped down the part of my code to write a test case and kept the stupid bits that I came up with some time ago to avoid "Invalid value for shared scalar" messages without understanding why they were appearing?
Thanks a bunch I now understand my error.For the record, I was assigning a thread object to an element of this shared hash, and using the above "strange overwriting technique" this somehow avoided the error message. Now I'm creating a "my" object reference, share it and assign it only then to the element of the shared hash.
Now this seems very complicated and I reckon I must have got lost somehow on the road. It's a bad idea to write production code whilst using modules for the first time, discovering design issues, circling back, discovering other issues... I think I'll start over ;-)
Now may I use your wisdom to get a hint on how you would design the code? Here's the big picture:
I'm simply trying to run multiple independent threads, each of which should periodically store some time-series numbers. Then a special thread would periodically take these numbers and do something with them (send them somewhere).
What I'm doing now is start the N threads plus the sending thread. Each thread handles its own infinite loop, and with its own interval. It stores its computed numbers in this shared hash. Now when the sending thread wakes up, it locks this hash, copies it to another, empties it and unlocks it. Then it can do whatever it likes with the copy
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^13: does threads (still) memleak?
by BrowserUk (Patriarch) on Nov 27, 2008 at 18:25 UTC | |
by faxm0dem (Novice) on Nov 28, 2008 at 14:11 UTC | |
by BrowserUk (Patriarch) on Nov 28, 2008 at 17:39 UTC | |
by faxm0dem (Novice) on Jan 14, 2009 at 16:14 UTC | |
by BrowserUk (Patriarch) on Jan 14, 2009 at 17:16 UTC |