Object handle given as parameter to different object in thread

[email protected] ((David Shapiro))
Newsgroups perl.ithreads
Organization PerlDiscuss.com
Message-ID <[email protected]>
Hello,

Do object filehandles passed into threaded function calls of another
object get destroyed upon a join, or do I need to clean that up? If it
does destroy it, what do I do if I do not want it to?  For example, one
object is shared  by multiple threaded objects, so I do not want it to go
out of scope with one of the threads using it.  

If I create one object like:

my $mail = Mail->new({ to => 'me', from => 'me', smtp => 'ms' });
(It has a sub DESTROY that prints it is getting destroyed)

and I assign it to other objects:

for (my $count = 0; $count < 3; $count++) {
   my $connection = Conn->new({ server => 'deathstar', mail => $mail });

   ...and then I call a function like so:

   eval {
      threads->new( \&Conn->destroyPlanet,$connection);
   };
}
my @threads = threads->list();
while(@threads) { eval { $_->join() };

David Shapiro
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.