<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></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=""><div bgcolor="#FFFFFF" text="#000000" class="">Having thought about it some more, I don't think it's enough to just
    protect calls to triggerEvent() because 'fTriggersAwaitingHandling'
    is still modified by BasicTaskScheduler::SingleStep().<br class=""></div></div></blockquote><div><br class=""></div>The intention of the code that implements “BasicTaskScheduler” was that:</div><div>1/ The event loop code (which is always just a single thread, remember) does nothing with “fTriggersAwaitingHandling” except clear (using “&=~”) a single bit that was already set, and</div><div>2/ The other thread(s) that can trigger event(s) do nothing with “fTriggersAwaitingHandling” except set (using “|=“) bit(s) that were not already set.</div><div><br class=""></div><div>If these two conditions are met, *and* if the ‘clear a bit’ and ‘set a bit’ operations are atomic, then the code will be thread-safe.</div><div><br class=""></div><div>(If, OTOH, you’re worried that the ‘clear a bit’ and ‘set a bit’ operations might not be atomic on your system, then you’d need to write your own “TaskScheduler” subclass instead.)</div><div><br class=""></div><div>Looking at the code again just now, however, I realized that the event loop code does not always satisfy condition 1/.   Line 183 of “BasicTaskScheduler.cpp” should be changed from:</div><div><span class="Apple-tab-span" style="white-space:pre">       </span>fTriggersAwaitingHandling = 0;</div><div>to</div><div><span class="Apple-tab-span" style="white-space:pre">      </span>fTriggersAwaitingHandling &=~ fLastUsedTriggerMask;</div><div><br class=""></div><div>I have just released a new version (2015.03.16) of the code that fixes this.  You should upgrade to this version.</div><div><br class=""></div><div><br class=""></div><div>You should also make sure that your own code satisfies condition 2/.  I.e., you should make sure that your code is never calling “triggerEvent()” more than once with the same ‘event trigger’ value, unless you’re sure that the first event (for that event trigger) has already been handled.  (In particular, you should never call “triggerEvent()” with the same ‘event trigger’ value from more than one thread.)</div><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><div class=""><br class="webkit-block-placeholder"></div>
<br class=""></body></html>