Thankyou for taking the time to find it again.

It's also nice to have my observations confirmed, and to see that it is mentioned in the documentation somewhere.

It would be nice it also got a mention in the threads::shared POD, along with a few examples of when lock needs to be used and when not. I'll try to produce a docu-patch for that.

So anyway, that text has led me to believe that a shared array used to implement a queue for passing data between threads would be safe, even with no locking, since the push() and shift() operations would be atomic in nature.

I've generally use Thread::Queue for implementing queues between threads. I tried it early on and it has never given me a problem, so I've stuck with it.

Re-reading perlthrtut, I agree with your reading that push and shift should be safe for this purpose. I'll probably have a play and see if I can break them.


Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.

In reply to Re^4: point #4 (Now what was that you were saying?) by BrowserUk
in thread Thoughts on how to devise a queryable win32 service by noslenj123

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.