Hello Brian,
Thanks for responding to my call for help.
Thanks for confirming my concerns on objects not being able to share across threads. I have a logger object which I want my threads to share and use. Is there any good workaround on this, short of just calling the class methods?
To clarify: I have the daemon run on its own thread. The main application spawns the daemon, which spawns the worker threads.
I will want the main application to periodically close all threads and restart them (I don't feel too comfortable with the stability of threads in Perl yet). So maybe after sleeping for 6 hours, it will stop and start the daemon thread.
I don't know if it is because my coding is too poor, but sometimes my threads will hang while processing stuff. If I can restart the threads regularly, it can be a safety net.
Thanks for the tip on the close() method. I will give it a try.
Wait a minute. The first paragraph said that the daemon was run in the main thread, now you say it is in its own thread? Which is it?
Anyhow, I believe that SOAP::Transport::HTTP is based on HTTP::Daemon
which is based on IO::Socket::INET so my first guess would be to call
'close' on the daemon object which would close the socket and cause the
'handle' function to exit. Have you tried that?
Third question (and last for this mail!): how can i kill a
thread from
the main app? ActivePerl does not support the thread::suspend module
(which has a kill() method), and I want to respect that. But
sometimes I really want to restart my worker threads.
The preferred way to terminate threads is cooperatively. That is, you give them a request to terminate, perhaps via the queue that you are already using, and wait for them to terminate.
However, if you intend to restart them, why do you want to terminate them?
HTH
_______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
