Although this adds nothing that cannot already be done, given the disconnect between establishing the return context at thread creation time, and its effect at thread join time, I do see the motivation behind wanting to make that context more explicit.

I do have to wonder at the need for two separate interfaces though?

thread->create( { context => 'list' }, ... # -v- thread->create( { list => 1 }, ...

The latter seems entirely redundant, and also wrong.

  1. This is a single option with 3 possibilities--not 3 binary options.
  2. It adds complexity where none is necessary or desirable.

    What context results from this?

    threads->create( { scalar => 1, void => 1, context => list, list => 0 +}, ...
  3. My main objection is the effect on performance.

    One of the main use of the return values/context is going to be applications that use the spawn & die mode of operation. Short lived threads that do something, return the results to the parent and exit. Spawn another for the next task. A typical example might be a threaded server.

    For this kind of application, the time taken for the spawning thread to start a thread and get back to deal with the next incoming connection is critical to the overall performance. Once a connection has been accepted, the time between the accept and the first read is not critical, but delays in getting back to service the next accept are.

    The additional complexity of parsing and validating the dual interface comes at a critical point in those applications that are most likely to make most use of them.


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: Explicit thread context by BrowserUk
in thread Explicit thread context 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.