<div class="gmail_quote">On Tue, Jan 19, 2010 at 5:30 AM, Andrei Alexandrescu <span dir="ltr"><<a href="mailto:andrei@erdani.com">andrei@erdani.com</a>></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;">
I uploaded draft 5 here:<br></blockquote></div><br>I'm reading and just got to the section on shutdown protocol.<br><br>Will all threads be delivered a single shutdown exception, after which they can do whatever they want, or will they get one every time they try to do a receive? The simple assumption is that you get all the shutdown exceptions you can eat, but I can imagine a number of cases where "just one" is better. Consider a simple processing flow:<br>
<br>A -> B -> C<br><br>A is producing data, sending it along to B, which does calculations, and sends them along to C. C caches data up and stores data in a database or the file-system. B is doing intermediate processing of some kind. Maybe A, B, and C are tiers of a web application. Now everyone starts getting shutdown exceptions.<br>
<br>Is there a way for B to send a final message to C (e.g. "save this draft of an email"), or C to A (a polite apology 'technical difficulty' message pulled from the database maybe)? It seems like it would be nice to have the messaging system when designing shutdown logic, even if main is shutting down.<br>
<br>If you think about it, there is no utility in any shutdown exception after the first one. If a thread doesn't catch it, it will terminate as expected. But as soon as a thread is going to catch one such message, then either it knows what it is doing or else it is already doomed in some way, another message won't be any more help.<br>
<br>If messaging does not exist then each component is suddenly going to need it's own filesystem or database persistence logic, which would reduce the one-actor-one-responsibility principle of the design.<br><br>(But either way it would be neat if the draft said which happens.)<br>
<br>Kevin<br><br>