in reply to Re^3: Should I use threads? Perl/DHCP/Radius
in thread Should I use threads? Perl/DHCP/Radius

I would use Threads::Queue to send messages back from your threads to your main thread instead of polling them for becoming ->joinable.

For passing thread results back otherwise, see threads, which documents the return value of ->join(). I would avoid using that, because to get more speed, you will want to keep a pool of worker threads and pass the queries to them using another Thread::Queue instead, thus saving the cost of creating and destroying a new thread for every request.

Replies are listed 'Best First'.
Re^5: Should I use threads? Perl/DHCP/Radius
by MonkeyMonk (Sexton) on Aug 25, 2010 at 14:12 UTC
    *Banging head against table* Thanks. I was searching for that precisely: sending back messages. Saw Threads::Queue yesterday and the words "Queue" dissuaded me from looking into the documentation.

      Still, in light of BrowserUks discussion, you should consider what the "main" thread is doing at all. I think that most of the work per-client can be done in a worker threads. Instead of just farming out the HTTP requests, I would farm out sending the responses to worker threads as well.