OwnerTerminated graceful handling

Eitan Frachtenberg etc at facebook.com
Mon Oct 11 11:45:27 PDT 2010


I still don't understand how it's supposed to work. Replace the line '(OwnerTerminated) { return; }' with '(MsgToClient) { return; }', where MsgToClient is an enum, still crashes gloriously with an OwnerTerminated exception. Is there any way I can cleanly stop a thread without crashing?
 
On Oct 7, 2010, at 10:38 AM, Sean Kelly wrote:

> Eitan Frachtenberg Wrote:
> 
>> N00b question: Based on the TPDL, explicitly receive()ing OwnerTerminated prevents an exception from throwing when the owner thread terminates. Yet this is exactly what happens in the following code:
>> 
>> import std.concurrency;
>> 
>> void thr() {
>>    receive(
>>      (OwnerTerminated) { return; }
>>   );
>> }
>> 
>> void main() {
>>  spawn(&thr);
>> }
>> 
>> Try to wrap the receive with a try/catch pair only causes a segfault, but that's not the point anyway. What am I missing something here?
> 
> You're missing the fact that I forgot to implement this feature :-)  Fixed in SVN.



More information about the Digitalmars-d mailing list