I've been trying a lot to find answers to these leaked scalar messages related to threads. I've given up. Life's too short. You shouldn't be getting them if your using "normal" (as in: non-XS) code, so you should consider them to be a bug in the threads::shared module.

However, I see you're using threads->yield(). In general I would say: don't. From the documentation:

threads->yield();
   This is a suggestion to the OS to let this thread
   yield CPU time to other threads.  What actually hap-
   pens is highly dependent upon the underlying thread
   implementation.
Furthermore from perlthrtut:

It is important to remember that yield() is only a hint to give up the CPU, it depends on your hardware, OS and threading libraries what actually happens. Therefore it is important to note that one should not build the scheduling of the threads around yield() calls. It might work on your platform but it won't work on another platform.

In my experience, under Linux yield() does nothing. So you're effectively burning all of your CPU in this loop:

while ( 1 ) { threads->yield; last if $thread_abort; next unless $thread_continue; ++$iter; }
I suggest you look at what you can do with lock(), cond_wait() and cond_signal() from threads::shared.

Hope this helps.

Liz

Update: added stuff about perlthrtut, which I guess should be in big, bold, red letters in the tutorial ;-)


In reply to Re: threads and leaking scalars by liz
in thread threads and leaking scalars by deliria

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.