<div class="gmail_quote">On Wed, Jan 20, 2010 at 1:50 AM, Andrei Alexandrescu <span dir="ltr">&lt;<a href="mailto:andrei@erdani.com">andrei@erdani.com</a>&gt;</span> 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="im">Sean Kelly wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
void fnB() {<br>
    // do something that takes a while<br>
}<br>
void fnA() {<br>
    spawn( &amp;fnB );<br>
}<br>
<br>
void main() {<br>
    auto tid = spawn( &amp;fnA );<br>
    tid.wait();<br>
}<br>
<br>
The main thread doesn&#39;t know the thread running fnB exists so it can&#39;t wait for it, even if it&#39;s doing completely legitimate work and shouldn&#39;t be interrupted.  How can I trivially rewrite this program so it completes without error?<br>

</blockquote>
<br></div>
If fnB does legitimate work and doesn&#39;t call concurrency-related routines, it will be waited for.<br>
<br>
If fnB does call concurrency-related routines, it must end when main() exits. To me exiting main() is a no-quarters situation: it means the application is to exit asap. I find it weird to think of programs that finish main() but continue to do stuff.<br>

<br>
To make sure everything is accounted for, the application design must be such that main() doesn&#39;t exit until useful threads are done.<br><font color="#888888">
<br>
<br>
Andrei</font><div><div></div><div class="h5"><br>
_______________________________________________<br>
dmd-concurrency mailing list<br>
<a href="mailto:dmd-concurrency@puremagic.com" target="_blank">dmd-concurrency@puremagic.com</a><br>
<a href="http://lists.puremagic.com/mailman/listinfo/dmd-concurrency" target="_blank">http://lists.puremagic.com/mailman/listinfo/dmd-concurrency</a><br>
</div></div></blockquote></div><br>