develooper Front page | perl.ithreads | Postings from December 2012

Re: Undefined thread object for main thread (tid zero) even thoughthe main thread exists

Thread Previous | Thread Next
From:
Mike Pomraning
Date:
December 3, 2012 15:25
Subject:
Re: Undefined thread object for main thread (tid zero) even thoughthe main thread exists
Message ID:
CAPZFfA-hxoROJMysd8PDC2qQjdFfbahHo8x0BYBWZHt_JPEwHw@mail.gmail.com
On Sun, Dec 2, 2012 at 10:53 PM, David Mertens <dcmertens.perl@gmail.com>wrote:

> ----%<----
>
> defined (threads->object($originating_tid{$name}))
>     or croak("retrieve_pdls: '$name' was created in a thread that "
>     . "is no longer available");
>
> ---->%----
>
> In my test suite, I create and store data in the main thread. For this
> example, then, $originating_tid{$name} == 0 for all cases considered. The
> problem is that only the main thread is capable of retrieving the threads
> object for tid 0. Any other (child) thread gets an undefined value. Does
> that surprise anyone? Are child threads able to get the thread objects for
> their parents or siblings?
>

I might be misreading this, but I believe that threads->object() ignores
detached threads unless a tid is explicitly passed in *and* that tid is the
tid of the calling thread.  The main thread is detached, so no thread other
than tid 0 can look it up via object().

(You describe an interesting problem and approach; do you have
demonstration code that others can take a look at?)

-Mike

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About