No such thing as a small change | |
PerlMonks |
Re: Kill and free the memory Never ending threads from mainby sundialsvc4 (Abbot) |
on Aug 25, 2013 at 14:51 UTC ( [id://1050861]=note: print w/replies, xml ) | Need Help?? |
Approach the problem this way: the event just means, “you should not be asleep right now.”   (Not “please wake up.”) The main-loop of the thread is driven by a set of shared flags which tell it what it should do next, one of the choices being “die now.”
The parent thread first sets one of the flags, then strobes the event to be sure that the child is not-asleep to respond to it. You don’t need to invent these things from scratch. Look at existing workhorses such as POE.
In Section
Seekers of Perl Wisdom
|
|