The attached code usually hangs (running on OSX, dmd 2.051).
It uses spawn to create a new thread. All the thread does is create a large
array of doubles. In one case it uses the Array!double from std.container. In
the other case it uses the built in dynamic double[]. It declares the array,
sets the length, then sends a message to main saying it is finished and exits.
The Array!double case always runs fine. The built-in dynamic array case
usually hangs, though not always in the same place.
And the array has to be sufficiently big (in my case 20 or bigger I think)
or the problem doesn't occur.
I've no idea why. It took me a *long* time to find this since it manifested
as very mysterious hanging in a more complex piece of threaded code. Now I've
switched to using Array!double in my code and it all works fine.
Adam
(An example run)
Spawned foo 1
Spawned foo 2
Spawned foo 3
Spawned foo 4
Finished foo 1
Finished foo 2
Finished foo 3
Finished foo 4
Spawned bar 1
Spawned bar 2
Spawned bar 3
(stays here without finishing)
begin 644 spawn.d
M:6UP;W)T('-T9YC;VYC=7)R96YC3L*:6UP;W)T('-T9YS=1I;SL*:6UP
M;W)T('-T9YC;VYT86EN97([FEM]R=!C;W)E+G1HF5A9#L*G9O:60@
M9F]O*'5I;G0@:RP@=6EN=!L+%1I9!M5ED*2`*PH@($%RF%Y(61O=6)L
M92!AG([B`@87)R+FQE;F=T:AL*3L*(!S96YD*U4:60L:RD[GT*@IV
M;VED()ABAU:6YT(LL('5I;G0@;Q4:60@;51I9D@GL*(!D;W5B;5;
M72!AG([B`@87)R+FQE;F=T:`](P[B`@V5N9AM5ED+LI.PI]@H*
M=F]I9!M86EN*D@GL*(!I;6UU=%B;4@=6EN=!M=6QT:7!L:65R(#T@
M,3`P,#`P.PH@(EM;75T86)L92!U:6YT(Y4:')E861S(#T@-#L*(!A=71O
M(UA:6Y4:60@/2!T:ES5ED*D[@H@(9OF5A8V@@*L[(#$N+BAN5AR
M96%DRLQ*2D@PH@(`@875T;R!D=6UM5]4:60@/2!S%W;B@F9F]O+LL
M:RIM=6QT:7!L:65R+UA:6Y4:60I.PH@(`@=W)I=5F;XH(E-P87=N960@
M9F]O(5S(BQK*3L*(!]@H@(9OF5A8V@H:SL@,XN;E1HF5A9',IB`@
M(!R96-E:79E*AU:6YT(HI('L@=W)I=5F;XH(D9I;FES:5D(9O;R`E
MR(L:BD[('TI.PH*(!F;W)E86-H(AK.R`Q+BXH;E1HF5A9',K,2DI('L*
M(`@(%U=\@9'5M;7E?5ED(#T@W!A=VXH)F)ABQK+LJ;75L=EP;EE
MBQM86EN5ED*3L*(`@('=R:71E9FQN*)3%W;F5D()AB`ER(L:RD[
MB`@?0H@(9OF5A8V@H:SL@,XN;E1HF5A9',IB`@(!R96-E:79E*AU
M:6YT(HI('L@=W)I=5F;XH(D9I;FES:5D()AB`ER(L:BD[('TI.PH@
(`H@(`I]
`
end