[dmd-concurrency] Shutdown protocol
Andrei Alexandrescu
andrei at erdani.com
Thu Jan 21 10:47:29 PST 2010
That's another great point! Thanks Steve.
Andrei
Steve Schveighoffer wrote:
> ----- Original Message ----
>
>> From: Andrei Alexandrescu <andrei at erdani.com>
>>
>> The way I see it is very simple: you have ample opportunity to do whatever you
>> deem appropriate for as long as main() runs. After that, it's in the hand of the
>> system, and the system is not responsible for giving quarters to unsaved data,
>> unclosed sockets etc.
>>
>> No mercy.
>
> Sounds like exit is a better fit then :)
>
> I would use the shutdown protocol only while still inside main:
>
> void main()
> {
> auto tids = [spawn(&appthread1), spawn(&appthread2)];
>
> waitForAppExit();
> shutdown(); // sends signals to all threads
> version(AndreisLaptop) WSACleanup();
>
> foreach(tid; tids) {tid.join();}
> writeln("shutting down!");
> // no mercy after this.
> }
>
> Why reserve the shutdown protocol for after main exits? At that point, the app is dead anyways.
>
> -Steve
>
>
>
>
> _______________________________________________
> dmd-concurrency mailing list
> dmd-concurrency at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-concurrency
More information about the dmd-concurrency
mailing list