<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div apple-content-edited="true"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: 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: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div><font class="Apple-style-span" color="#0000FF" face="'Gill Sans'"><span class="Apple-style-span" style="font-size: medium;">This sounds like a great plan. To be honest, checking the multiple join error is not hard to do in any implementation.</span></font></div></span></span></span></span></span></span></span></span></div></span></div></span> </div><br><div><div>On 3 Nov 2009, at 11:31, Randy Coleburn wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="WORD-WRAP: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space"> <div>I guess I will need to go back and look at Nelson again, but is it possible that one of the subsequent editions of SPwM3 added this prohibition against multiple joins? I seem to recall that some of the interfaces got a rework and were published after the first printing of the book, but that the community adopted these as a whole to be "the spec" for M3. Maybe the comment in Thread.i3 became law at that point?</div> <div> </div> <div>In any event, I still argue that it doesn't make sense to do multiple joins and I agree with Mika that it is often a symptom of bad programming and we want the language to help us write less buggy code. </div> <div> </div> <div>So, I would vote that we don't make any <u>changes</u> to permit multiple joins. It may be true that the current implementation does not enforce the prohibition against multiple joins on all platforms simply because it was the easiest thing to do at the time. In this case, I argue that the implementation is not being totally faithful to the specification; but if the programmer heeds the spec, then there is no consequence to the implementation's lack of enforcement.</div> <div> </div> <div><strong><u>Bottom line</u></strong>: Let's not devolve from the noble position of doing the right thing simply because the implementation has been less than faithful. Keep the comment and the prohibition and work toward improving the implementation <u>over time</u> to be faithful to the specification. (Does that make me a "practical idealist"?)</div> <div> </div> <div>Regards,</div> <div>Randy Coleburn<br><br>>>> Tony Hosking <<a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a>> 11/3/2009 11:09 AM >>><br></div> <div apple-content-edited="true"><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -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: 0"> <div style="WORD-WRAP: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space"><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto"> <div style="WORD-WRAP: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space"><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto"><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto"><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto"><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto"><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto"><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto"><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto"><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto"> <div><span class="Apple-style-span" style="FONT-SIZE: medium">On 3 Nov 2009, at 10:49, Randy Coleburn wrote:</span></div></span></span></span></span></span></span></span></span></div></span></div></span></div> <div><br class="Apple-interchange-newline"> <blockquote type="cite"><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: medium Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -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"> <div class="hmmessage" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"> <div>Understand the part about being "torn".</div> <div> </div> <div>I for one, have always programmed with the understanding that the comment was enforced.</div> <div> </div> <div>IMO: If one needs to pass the result of a thread outside the thread's context, one should use an explicit mechanism or data structure (e.g., conditions, object data fields, etc.).</div> <div> </div> <div>If multiple threads need to wait for a thread to finish, that is the whole concept of a rendevous (see the "Little Book of Semaphores" you referenced earlier). </div></div></span></blockquote> <div><br></div> <div>Agreed.</div><br> <blockquote type="cite"><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: medium Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -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"> <div class="hmmessage" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"> <div> If programmers must depend on multiple joins, when is it ever safe for the underlying infrastructure to "forget about" the dead thread and its return value(s), if any? At what point has it been "too long" for you to query about a dead thread's status/return values (millisecs, minutes, hours, days, weeks -- for long-running programs this can be problematic).</div></div></span></blockquote> <div><br></div> <div>We can forget about the dead thread only when it is GC'd. No-one can call Join without a reference to it.</div><br> <blockquote type="cite"><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: medium Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -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"> <div class="hmmessage" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"> <div> I would argue that it is better for the programmer to be explicit in such matters. It is easy enough to implement given the capabilities of the language, and indeed, I've done so many times.</div></div></span></blockquote> <div><br></div> <div>Agreed. The odd thing is just that the old "reference" user-level threads implementation never did the check, and permitted multiple joins. And the threads spec in SPwM3 is silent on the issue.</div><br> <blockquote type="cite"><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: medium Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -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"> <div class="hmmessage" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"> <div>Regards,</div> <div>Randy Coleburn<br><br>>>> Jay K <<a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a>> 11/3/2009 10:04 AM >>><br>To me..with a Win32 background..join means "wait for thread to finish".<br>And there is a separate action "get thread result".<br>You could consider these one merged operation "wait for thread to finish and get its result".<br>In either case, it is reasonable to allow it multiple times.<br>Waiting for a thread to finish that has already finished is just fast.<br>Getting a thread result that you already got is also easy albeit usually unnecessary.<br> <br>Now, if the operation is "wait for thread to finish, get its result, and lose track of its result",<br>that isn't idempotent.<br> <br>I'm torn. The existing implementations all either support multiple join or have to go out of<br>their way to prevent it. Yet Thread.i3 has been commented so presumably forever.<br> <br> - Jay<br><br> <br></div> <div> <hr id="stopSpelling"> </div> <div>Date: Tue, 3 Nov 2009 09:36:23 -0500<br>From:<span class="Apple-converted-space"> </span><a href="mailto:rcoleburn@scires.com">rcoleburn@scires.com</a><br>To:<span class="Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>Subject: Re: [M3devel] join twice?<br><br></div> <div>I think the comment in the code is correct.</div> <div> </div> <div>Semantically, it doesn't make sense to join a thread more than once. Join is the compliment to Fork. With fork, one thread becomes two. With Join, two threads become one. After they've become one, the 2nd thread is no more, so you can't join to it anymore.</div> <div> </div> <div>IMO, the implementation should enforce this behavior. What would be the "benefit" of allowing more than one join? What does it "mean" to join a "dead thread"?</div> <div> </div> <div>Regards,</div> <div>Randy Coleburn<br><br>>>> Tony Hosking <<a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a>> 11/2/2009 11:54 PM >>><br></div> <div><span class="ecxApple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"> <div style="WORD-WRAP: break-word"><span class="ecxApple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"> <div style="WORD-WRAP: break-word"><span class="ecxApple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><span class="ecxApple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><span class="ecxApple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><span class="ecxApple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><span class="ecxApple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><span class="ecxApple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><span class="ecxApple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><span class="ecxApple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"> <div><font class="ecxApple-style-span" face="'Gill Sans'" color="#0000ff"><span class="ecxApple-style-span" style="FONT-SIZE: medium">OK, sure. Fair enough.</span></font></div></span></span></span></span></span></span></span></span></div></span></div></span></div><br> <div> <div>On 2 Nov 2009, at 16:43, Jay K wrote:</div><br class="ecxApple-interchange-newline"> <blockquote><span class="ecxApple-style-span" style="WORD-SPACING: 0px; FONT: medium Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"> <div class="ecxhmmessage" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana"> > (Whether the implementation actually prohibits it or not is an implementation decision.) <span class="ecxApple-converted-space"> </span><br><br>Tony, I'm sympathetic to the smaller version but I think it is wrong.<br>"It is a checked runtime error to call this more than once for any t"<br>is a much different/stronger statement than e.g.<br>"it is implementation defined what happens if you call join more than once for any t".<br>The printed Reactor 4.1 docs have the same comment as current Thread.i3.<br> <br>You know, ideally if I write:<br>Thread.Join(t);<br>Thread.Join(t);<br><br>and it works today on any system, it will continue to work on all systems.<br>I think "implementation defined" is something Modula-3 tries to have less of.<br> <br>On the other hand, I think if we foresee it to work trivially on all<br>forseeable implementations, we can change the interface by removing the comment.<br>Win32 WaitForSingleObject(thread, INFINITE) is allowed multiple times, though<br>that isn't the current implementation.<br><br> - Jay<br> <br> <hr id="ecxstopSpelling"> From:<span class="ecxApple-converted-space"> </span><a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a><br>To:<span class="ecxApple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>Date: Mon, 2 Nov 2009 12:59:36 -0500<br>CC:<span class="ecxApple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>Subject: Re: [M3devel] join twice?<br><br>I don't know that there ever was a mandate that join can only be called once on a given thread. But, given that pthread_join is undefined when called more than once on the same thread we probably want to retain the comment. (Whether the implementation actually prohibits it or not is an implementation decision.) The point is that we should be free to give the error in some later implementation, so as to not to restrict what semantics the implementation must support. <div><br> <div><span class="ecxecxApple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"> <div style="WORD-WRAP: break-word"><span class="ecxecxApple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"> <div style="WORD-WRAP: break-word"><span class="ecxecxApple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><span class="ecxecxApple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><span class="ecxecxApple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><span class="ecxecxApple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><span class="ecxecxApple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><span class="ecxecxApple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><span class="ecxecxApple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"><span class="ecxecxApple-style-span" style="WORD-SPACING: 0px; FONT: 12px Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"> <div><font class="ecxecxApple-style-span" color="#0000ff"><font class="ecxecxApple-style-span" face="Gill Sans"><span class="ecxecxApple-style-span" style="COLOR: rgb(0,0,255); FONT-FAMILY: 'Gill Sans'"><span class="ecxecxApple-style-span" style="COLOR: rgb(0,0,255); FONT-FAMILY: 'Gill Sans'">Antony Hosking</span></span></font></font><font class="ecxecxApple-style-span" face="Gill Sans"><span class="ecxecxApple-style-span" style="FONT-FAMILY: 'Gill Sans'"><span class="ecxecxApple-style-span" style="FONT-FAMILY: 'Gill Sans'"><span class="ecxecxApple-converted-space"> </span>|<span class="ecxecxApple-converted-space"> </span></span></span><span class="ecxecxApple-style-span" style="FONT-FAMILY: 'Gill Sans'"><span class="ecxecxApple-style-span" style="FONT-FAMILY: 'Gill Sans'">Associate Professor</span></span><span class="ecxecxApple-style-span" style="FONT-FAMILY: 'Gill Sans'"><span class="ecxecxApple-style-span" style="FONT-FAMILY: 'Gill Sans'"> | Computer Science | Purdue University</span></span></font></div> <div><font class="ecxecxApple-style-span" face="GillSans-Light"><span class="ecxecxApple-style-span" style="FONT-FAMILY: GillSans-Light">305 N. University Street | West Lafayette | IN 47907 | USA</span></font></div> <div><font class="ecxecxApple-style-span" face="Gill Sans" color="#0000ff"><span class="ecxecxApple-style-span" style="COLOR: rgb(0,0,255); FONT-FAMILY: 'Gill Sans'"><span class="ecxecxApple-style-span" style="COLOR: rgb(0,0,255); FONT-FAMILY: 'Gill Sans'">Office</span></span></font><font class="ecxecxApple-style-span" face="GillSans-Light"><span class="ecxecxApple-style-span" style="FONT-FAMILY: GillSans-Light"><span class="ecxecxApple-style-span" style="FONT-FAMILY: GillSans-Light"> +1 765 494 6001 |<span class="ecxecxApple-converted-space"> </span></span></span></font><font class="ecxecxApple-style-span" face="Gill Sans" color="#0000ff"><span class="ecxecxApple-style-span" style="COLOR: rgb(0,0,255); FONT-FAMILY: 'Gill Sans'"><span class="ecxecxApple-style-span" style="COLOR: rgb(0,0,255); FONT-FAMILY: 'Gill Sans'">Mobile</span></span></font><font class="ecxecxApple-style-span" face="GillSans-Light"><span class="ecxecxApple-style-span" style="FONT-FAMILY: GillSans-Light"><span class="ecxecxApple-style-span" style="FONT-FAMILY: GillSans-Light"><span class="ecxecxApple-converted-space"> </span>+1 765 427 5484</span></span></font></div> <div><font class="ecxecxApple-style-span" face="GillSans-Light"><br class="ecxecxkhtml-block-placeholder"></font></div></span></span></span></span></span></span></span><br class="ecxecxApple-interchange-newline"></span></div></span></div></span><br class="ecxecxApple-interchange-newline"></div><br> <div> <div>On 2 Nov 2009, at 10:11, Jay K wrote:</div><br class="ecxecxApple-interchange-newline"> <blockquote><span class="ecxecxApple-style-span" style="WORD-SPACING: 0px; FONT: medium Helvetica; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate"> <div class="ecxecxhmmessage" style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana">Thread.i3:<br> <br> <br>PROCEDURE Join(t: T): REFANY;<br>(* Wait until "t" has terminated and return its result. It is a<br> checked runtime error to call this more than once for any "t". *)<br><br> <br>ThreadWin32.m3:<br> <br> <br>PROCEDURE Join(t: T): REFANY =<br> VAR res: REFANY;<br> BEGIN<br> LOCK t DO<br> IF t.joined THEN Die(ThisLine(), "attempt to join with thread twice"); END;<br> WHILE NOT t.completed DO Wait(t, t.join) END;<br> res := t.result;<br> t.result := NIL;<br> t.joined := TRUE;<br> t.join := NIL;<br> END;<br> RETURN res;<br> END Join;<br> <br>PROCEDURE AlertJoin(t: T): REFANY RAISES {Alerted} = similar<br><br><br>ThreadPThread.m3:<br> <br><br>PROCEDURE Join (t: T): REFANY =<br> BEGIN<br> LOCK t DO<br> WHILE NOT t.completed DO Wait(t, t.join) END;<br> END;<br> RETURN t.result;<br> END Join;<br> <br>PROCEDURE AlertJoin (t: T): REFANY RAISES {Alerted} = similar<br><br> <br>Should we just loosen the comment and go with the simpler pthread version?<br>I'd like Win32 and pthread to be more similar where possible, to ease maintenance.<br> <br> <br> - Jay<br></div></span></blockquote></div><br></div></div></span><br class="ecxApple-interchange-newline"></blockquote></div><br></div></span><br class="Apple-interchange-newline"></blockquote></div><br></div></blockquote></div><br></body></html>