Re: [Issue 4307] New: spawn()'ed thread doesn't terminate

2010-06-17 Thread Sean Kelly
Never mind, I'll fix it.  This will require adding an atexit() sort of routine 
to druntime, which I believe was requested in another ticket anyway.


Re: [Issue 4307] New: spawn()'ed thread doesn't terminate

2010-06-15 Thread Sean Kelly
The main thread is somewhat special in D--it doesn't actually terminate until 
all other threads have terminated.  And because the OwnerTerminated message 
is sent in a static dtor, the ordering is wrong for having spawned threads 
receive this message.  I'll leave it up to Andrei to decide whether this is 
correct behavior or if the OwnerTerminated message should be sent when D main() 
exits (I'm leaning towards this latter behavior myself).  If a change is 
necessary I'll have to add a stack for onMainExit callbacks to be executed in 
druntime.


[Issue 4307] New: spawn()'ed thread doesn't terminate

2010-06-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4307

   Summary: spawn()'ed thread doesn't terminate
   Product: D
   Version: D2
  Platform: x86
OS/Version: Windows
Status: NEW
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: to...@yahoo.com


--- Comment #0 from to...@yahoo.com 2010-06-13 18:50:11 PDT ---
Using DMD 2.047.

This example hangs after printing '9'.  From reading Andrei's book, my
understanding is that the spawned thread should terminate automatically when
its owner thread terminates.  But that doesn't happen here.

---
import std.concurrency;
import std.stdio;

void f()
{
for (;;)
{
int i = receiveOnly!int();
writeln(i);
}
}

void main()
{
Tid tid = spawn(f);
foreach (int i; 0..10)
{
send(tid, i);
}
}
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---