Foo Ji-Haw wrote: > Hi all, > > I am exploring the use of ithreads in a service application that I am > developing. Generally, the main thread is a > SOAP::Transport::HTTP daemon > that spawns worker threads at the onset. Whenever it receives a SOAP > method call, it will send out jobs to the worker threads via > thread::queue. Whichever receives the job in the ::queue will > work on it. > > I am having some difficulties understanding (i)threading and > SOAP::Transport::HTTP in Perl. The first of which is: how can my main > application (which created the SOAP::Transport::HTTP daemon > in a thread > of its own) stop/ kill the daemon thread without kill the > whole app? I > tried use thread::exit and call exit() in the daemon module, > but it did > not work.
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? > > Next question: is there any way I can have my worker threads share an > object? threads::shared seems to accomodate only simple scalars. If you mean objects, as in blessed references, then yes there are difficulties with sharing these between threads. But if you mean arrays and hashes, then these can be shared, see 'perldoc perlthrtut'. > > 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 -- Brian Raven ----------------------------------------------------------------------- The information contained in this e-mail is confidential and solely for the intended addressee(s). Unauthorised reproduction, disclosure, modification, and/or distribution of this email may be unlawful. If you have received this email in error, please notify the sender immediately and delete it from your system. The views expressed in this message do not necessarily reflect those of LIFFE Holdings Plc or any of its subsidiary companies. ----------------------------------------------------------------------- _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
