digitalmars.D - OwnerTerminated graceful handling
- Eitan Frachtenberg (16/16) Oct 06 2010 N00b question: Based on the TPDL, explicitly receive()ing OwnerTerminate...
- Sean Kelly (2/17) Oct 07 2010 You're missing the fact that I forgot to implement this feature :-) Fix...
- Eitan Frachtenberg (10/29) Oct 11 2010 I still don't understand how it's supposed to work. Replace the line '(O...
- Sean Kelly (3/27) Oct 13 2010 I'm not sure if you've read TDPL, but the basic idea is that if thread A...
- Eitan Frachtenberg (12/16) Oct 13 2010 spawns threads B and C, B and C should typically not outlive thread A. ...
- sybrandy (4/17) Oct 07 2010 I've seen the same issue. From what I've seen, std.concurrency is still...
N00b question: Based on the TPDL, explicitly receive()ing OwnerTerminated p= revents an exception from throwing when the owner thread terminates. Yet th= is 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 t= hat's not the point anyway. What am I missing something here? Thanks, --Eitan.
Oct 06 2010
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.
Oct 07 2010
I still don't understand how it's supposed to work. Replace the line '(Owne= rTerminated) { return; }' with '(MsgToClient) { return; }', where MsgToClie= nt is an enum, still crashes gloriously with an OwnerTerminated exception. = Is there any way I can cleanly stop a thread without crashing? =20 On Oct 7, 2010, at 10:38 AM, Sean Kelly wrote:Eitan Frachtenberg Wrote: =20d prevents an exception from throwing when the owner thread terminates. Yet= this is exactly what happens in the following code:N00b question: Based on the TPDL, explicitly receive()ing OwnerTerminate=t that's not the point anyway. What am I missing something here?=20 import std.concurrency; =20 void thr() { receive( (OwnerTerminated) { return; } ); } =20 void main() { spawn(&thr); } =20 Try to wrap the receive with a try/catch pair only causes a segfault, bu==20 You're missing the fact that I forgot to implement this feature :-) Fixe=d in SVN.
Oct 11 2010
I'm not sure if you've read TDPL, but the basic idea is that if thread A spawns threads B and C, B and C should typically not outlive thread A. Manual cleanup of spawned threads tends to be messy, so this functionality was built into the messaging system as the OwnerTerminated exception. So currently, if a spawned thread should outlive its creator it should receive OwnerTerminated and ignore it. I've added the beginnings of bidirectional linking as well via spawnLinked and the LinkTerminated exception, so monitor threads can be created to track the status of worker threads. There is still a lot of functionality missing however. Eitan Frachtenberg Wrote: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.
Oct 13 2010
On Oct 13, 2010, at 10:09 AM, Sean Kelly wrote:I'm not sure if you've read TDPL, but the basic idea is that if thread A =spawns threads B and C, B and C should typically not outlive thread A. Man= ual cleanup of spawned threads tends to be messy, so this functionality was= built into the messaging system as the OwnerTerminated exception. So curr= ently, if a spawned thread should outlive its creator it should receive Own= erTerminated and ignore it.=20 I've added the beginnings of bidirectional linking as well via spawnLinke=d and the LinkTerminated exception, so monitor threads can be created to tr= ack the status of worker threads. There is still a lot of functionality mi= ssing however.=20Yes, I have read TDPL. I suppose I don't really care about spawned worker t= hreads outliving owner thread, as long as the owner has a clean way to sign= al to the worker that it should stop now.
Oct 13 2010
On 10/06/2010 07:48 PM, 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? Thanks, --Eitan.I've seen the same issue. From what I've seen, std.concurrency is still a work in progress, so hopefully the bugs will get worked out soon. Casey
Oct 07 2010