Hey I prefer Tom's version! I shouldn't be racy if I read the resumeProcess and resume code correctly. The resumeProcess message has no effect on non-waiting processes!<br><br>> | waitingProcess wakeupProcess |
<br>> waitingProcess _ Processor activeProcess.<br>> wakeupProcess _<br>> [(Delay forMilliseconds: (anInteger max: 0)) wait.<br>> self resumeProcess: waitingProcess] fork.
<br>><br>> self wait.<br> "preempting here and getting the resumeProcess message sent would have no effect - therefore no race!"<br> "in comparison having a semaphore getting signaled here would cause an excess signal on the sem: bad"
<br>> wakeupProcess terminate.<br><br>Cheers!<br>Georg<br><br><div class="gmail_quote">On Jan 5, 2008 9:43 AM, Andreas Raab <<a href="mailto:andreas.raab@gmx.de">andreas.raab@gmx.de</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">Tom Phoenix wrote:<br>> Is that the source in your image for that method? Here's what I have:<br>><br>> waitTimeoutMSecs: anInteger<br>> "Wait on this semaphore for up to the given number of milliseconds,
<br>> then timeout. It is up to the sender to determine the difference<br>> between the expected event and a timeout."<br>><br>> | waitingProcess wakeupProcess |<br>> waitingProcess _ Processor activeProcess.
<br>> wakeupProcess _<br>> [(Delay forMilliseconds: (anInteger max: 0)) wait.<br>> self resumeProcess: waitingProcess] fork.<br>><br>> self wait.
<br>> wakeupProcess terminate.<br><br></div>How odd. It seems that this version is only present in 3.9 - all other<br>images have a variant of the (much simpler) code:<br><div class="Ih2E3d"><br>waitTimeoutMSecs: anInteger
<br> "Wait on this semaphore for up to the given number of milliseconds,<br>then timeout. It is up to the sender to determine the difference between<br>the expected event and a timeout."<br></div><div class="Ih2E3d">
| d |<br> d := Delay timeoutSemaphore: self afterMSecs: (anInteger max: 0).<br></div> [self wait] ensure:[d unschedule].<br><br>The 3.9 version is tagged "jf 12/2/2003" but there is no indication what
<br>it is trying to address (if anything).<br><br>Cheers,<br><font color="#888888"> - Andreas<br><br></font></blockquote></div><br>