I'm gonna pick out two paragraphs from your write-up on PSiCHE, that I think states one of the limitations of iThreads infinitely more clearly than I've ever been able to say it, or any other desceription I've ever read.

Within Perl's current ithreads implementation, variables are private to each thread, and each newly created thread gets a private copy of each existing variable. All of which may seem reasonable...until your threads need to share information. Enter threads::shared, which defines a simple interface to declare a variable as "shared".

Unfortunately, threads::shared imposes a significant burden: since all threads::shared variables are managed within a single shared Perl interpretter context, a single global lock on that context must be acquired before any thread can do anything to any thread::shared variable. No matter if each thread is referencing completely different variables, and is only doing read operations, they all must first exclusively acquire the global lock before accessing the shared variables (Frankly, it calls into question the point of providing application-level locking primitives). The problem is exacerbated by the frequent reference count adjustments applied to the shared variables as various threads create and destroy proxy versions and references.

Maybe, if any of the people that count have been following along on my recent crusade on the future of threads, and are still paying some attention, this might do some good.

I'm particularly taken by the emboldened sentence (my emphasis), as oft times, when I've attempted to detect race conditions on my single cpu system by omitting user locking, I've failed. My code has been 'accidentaly protected' by the locking Perl uses to protect it's internals. This has caused me to question the need for user locking on single cpu systems on several occasions.

Of course, ikegami's recent tutorial builds on Dave_the_m's earlier elegantly simple and informative, but easily missed or forgotten answer, to confirm that user locks are needed.

(Ps. I've looked for a way to replace threads::shared for ages, but it looks like you have something that really might fly. Keep up the great work!)


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^2: iThreads for OOP by BrowserUk
in thread iThreads for OOP by Zukoff

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.