<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">The volatile keyword makes no difference for memory access rules in multiple threads.</div></blockquote><div><br class=""></div>Yes, but the only real concern in this particular case (because of the very limited way in which the shared ‘watch variable' is checked/set by multiple threads) is compiler optimization.  I.e., you’re concerned about a compiler ‘optimizing'</div><div><br class=""></div><div>void foo(char* watchVariable) {<br class=""><span class="Apple-tab-span" style="white-space:pre">    </span>while (1) {<br class=""><span class="Apple-tab-span" style="white-space:pre">               </span>if (*watchVariable != 0) break;<br class=""><span class="Apple-tab-span" style="white-space:pre">              </span>bar();<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>}<br class="">}</div><div><br class=""></div><div>to</div><div><br class=""></div><div>void foo(char* watchVariable) {</div><div><span class="Apple-tab-span" style="white-space:pre">     </span>if (*watchVariable != 0) return;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>while (1) bar();</div><div>}</div><div><br class=""></div><div>I don’t know of any compiler that would do this (because they seem to usually be quite conservative about the values of deferenced pointers), but I guess it’s possible.  So your point is well-taken; I should change the watch variable type to be “char volatile*”.</div><div><br class=""></div><div>But again, this issue is moot wrt. VLC, so I apologize for the diversion :-)<br class=""></div><br class=""><br class=""><div apple-content-edited="true" class="">
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;  "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;  ">Ross Finlayson<br class="">Live Networks, Inc.<br class=""><a href="http://www.live555.com/" class="">http://www.live555.com/</a></span></span>
</div>
<br class=""></body></html>