Concurrency Confusion

sigod via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Aug 10 15:50:14 PDT 2015


On Monday, 10 August 2015 at 22:21:18 UTC, 岩倉 澪 wrote:
> On Saturday, 8 August 2015 at 06:24:30 UTC, sigod wrote:
>> Use negative value for `receiveTimeout`. 
>> http://stackoverflow.com/q/31616339/944911
>
> actually this no longer appears to be true?
> Passing -1.msecs as the duration gives me an assertion failure:
>
>>core.exception.AssertError at std/concurrency.d(1902): Assertion 
>>failure
>
> Took a look in phobos and it appears to be from this line:
> https://github.com/D-Programming-Language/phobos/blob/master/std/concurrency.d#L1904

It looks like you're trying to use `receiveTimeout` like this:

     bool value;
     receiveTimeout(-1.msecs, value);

But you must use it like this:

     bool value;
     receiveTimeout(-1.msecs, (bool b) { value = b; });

See [`receive`][0] for example.

[0]: http://dlang.org/phobos/std_concurrency.html#.receive


More information about the Digitalmars-d-learn mailing list