Re: Best Practice For Killing Thread?

[email protected] (Mike Pomraning)
Newsgroups perl.ithreads
Message-ID <[email protected]>
On Mon, 3 Nov 2003, Steve Schein wrote:

> >>> Hello Mike.  Thanks so much for your pipe suggestion.  It looks very
> interesting and I will study it promptly.  I'll let you know how it
> goes.

Thanks; most of what applies to pipes as interprocess synch/communication
devices applies to intraprocess designs, too.  The tricky part in Perl might
be making sure that the close() succeeds -- if more than one thread has a
filehandle referring to W, I think Perl will keep the underlying fd open.

You could instead print a message to the pipe to make it select readable.
That'd avoid the concern above, and let you send arbitrary messages over a
private command channel ("QUIT", "REINITIALIZE", etc.).  Only caveat here
would be to set autoflushing on the W handle.

> subsequent threads are launched they don't seem to use thread id's that
> have been consequently re-opened.  This gives the impression that the

I believe the current implementation simply increments a "next tid" counter,
rather than re-using old tids.  (I'd argue that this is desirable.)  For
detached threads, there isn't really a way to figure out if the thread has
been internally reclaimed.

Regards,
Mike
-- 
Michael J. Pomraning
[email protected]
http://pilcrow.madison.wi.us
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.