in reply to Re^4: Should I use threads? Perl/DHCP/Radius
in thread Should I use threads? Perl/DHCP/Radius
The concept is simple. Have a shared hash or array where each thread can write to a scalar. Have a timer ;-) in the main thread loop thru the hash, and make logical descisions for you.
You have 2 ways of sending messages back from child thread to master thread. One is shared variables, two is thru the fileno's on the open filhandles( which all threads share). You can open a filehandle in the mainthread to listen to with a fileevent method, then have the spawned threads write to that filehandle so that the mainthread can listen for synchronization data.
Also remember to save the tid's ( thread ids) as you spawn them, so your parent thread can join them later, to destroy them. Just Another Hash Problem. ;-) See Reusable threads demo for enlightenment. P.S. Read the replies for a higher level of enlightenment. :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Should I use threads? Perl/DHCP/Radius
by BrowserUk (Patriarch) on Aug 25, 2010 at 14:38 UTC | |
by zentara (Cardinal) on Aug 25, 2010 at 14:45 UTC | |
by roboticus (Chancellor) on Aug 25, 2010 at 15:17 UTC | |
by zentara (Cardinal) on Aug 25, 2010 at 15:20 UTC | |
by BrowserUk (Patriarch) on Aug 25, 2010 at 15:11 UTC | |
by zentara (Cardinal) on Aug 25, 2010 at 15:18 UTC | |
by BrowserUk (Patriarch) on Aug 25, 2010 at 15:31 UTC | |
|