[dmd-concurrency] Shutdown protocol

Steve Schveighoffer schveiguy at yahoo.com
Thu Jan 21 10:43:31 PST 2010


----- 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



      


More information about the dmd-concurrency mailing list