Problems with receive

Stanislav Blinov stanislav.blinov at gmail.com
Sun Aug 29 13:19:23 PDT 2010


Bob Cowdery wrote:
>  On 29/08/2010 20:17, Stanislav Blinov wrote:
>> Stanislav Blinov wrote:
>>
>>> I'm not sure about Variant part yet (never tried it myself)
>> Hmm, after some inspection I can say this is an implementation issue.
>>
>> You'll find that there are cases when what's told in TDPL doesn't work
>> (see recent msg[0] or msg.field[0]? in this group, for example). I'
>> for example, have just found that receive(OwnerTerminated) doesn't
>> work as well. It's just that current dmd and phobos implementations
>> need time to catch up TDPL (I know, things often go in reverse, but
>> with D it's not the case :) )
> That's a shame because a  catch all is really needed.  I hope the
> timeout works, not tried that yet. I will probably have explicit thread
> termination so if OwnerTerminated if a bit broken it's not so important
> to me but to be able to catch rogue messages and find out what they were
> is quite key.

Well, I'm not ready to file a bug report yet, but if you're desperate, I 
*think* this may do the trick for you (assuming you use 2.048):

in std/concurrency.d, line 382:

Change
if ( i < T.length )
to
static if ( i < T.length-1 )

This works (for me, at least), even without recompilation of phobos.
Mind you, I propose a hack made by hand, and Sean Kelly or other pros 
here may well find that I'm wrong, so it's at your own risk :)


More information about the Digitalmars-d-learn mailing list