[dmd-concurrency] draft 5

Kevin Bealer kevinbealer at gmail.com
Tue Jan 19 22:54:50 PST 2010


On Wed, Jan 20, 2010 at 1:50 AM, Andrei Alexandrescu <andrei at erdani.com>wrote:

> Sean Kelly wrote:
>
>> void fnB() {
>>    // do something that takes a while
>> }
>> void fnA() {
>>    spawn( &fnB );
>> }
>>
>> void main() {
>>    auto tid = spawn( &fnA );
>>    tid.wait();
>> }
>>
>> The main thread doesn't know the thread running fnB exists so it can't
>> wait for it, even if it's doing completely legitimate work and shouldn't be
>> interrupted.  How can I trivially rewrite this program so it completes
>> without error?
>>
>
> If fnB does legitimate work and doesn't call concurrency-related routines,
> it will be waited for.
>
> 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.
>
> To make sure everything is accounted for, the application design must be
> such that main() doesn't exit until useful threads are done.
>
>
> Andrei
>
> _______________________________________________
> dmd-concurrency mailing list
> dmd-concurrency at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-concurrency
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-concurrency/attachments/20100120/115696a9/attachment.htm>


More information about the dmd-concurrency mailing list