I think that renodino's idea of a separate api for setting the default stacksize is a good one. I'd store the value into the PerlIterpreter struct (interp.h) with a default value similar to the current stacksize setting for compatibility. Once altered, and new threads would inherit the new size. If it gets reset in a spawned thread, any threads spawned from that thread would inherit the new value.

That does mean your separate package would have a dependancy upon the addition of that new field to the core, but I don't see why that would be a show stopper.

I'd also add an extended threads->create() method, (maybe threads->createEx() if that's not 'too MS'?), that took a hashref as the first parameter and the standard args thereafter. The contents of the hashref would be a set of (potentially platform specific), named args that would be passed either directly or in modified form to the CreateThread()/pthreads_create() calls. If the hashref was empty (or undef is passed) then it maps to the normal create() method.

The keynames could be mapped to the standard parameter names used by the platform api docs, giving you a pretty extensible api that would allow for future expansion if the need arises. For example, I could see the possibility of passing a SECURITY_ATTRIBUTES structure being a useful facility.

While you're there :), could you also add an instance method for accessing the native thread handle from the Perl thread object $threadObject->getNative()?

That would facilitate using platform specific apis (like SetThreadPriority(), suspend/resumeThread(), pthreads_suspend_np() etc.), from add-on packages without requiring the main threads package to support everything for all platforms.


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: New threads->create() syntax by BrowserUk
in thread New threads->create() syntax by jdhedden

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.