in reply to Re: Using Select and pipes to communicate with threads
in thread Using Select and pipes to communicate with threads

How would you modify this so that the main process could send messages/data to the threads?

Pass 2 pipes to each thread? set the second pipe as reader in the thread and writer in the main thread. Probably you would have to stuff the pipe filehandles in a hash in the main thread, so you could keep track of which pipe writes to which thread. I suppose you can run IO::Select in each thread to watch for messages, or setup an eventloop to watch the filehandle, or a basic loop of some sort.

I will work on an example. :-)


I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh
  • Comment on Re^2: Using Select and pipes to communicate with threads