std.concurrency msg passing

Ali Çehreli acehreli at yahoo.com
Thu Oct 18 10:50:03 PDT 2012


On 10/17/2012 11:29 PM, Joshua Niehus wrote:
> Is the following snippet a bug?
>
> ---
> import core.thread;
> import std.stdio, std.concurrency;
>
> void foo(Tid tid) {
> send(tid, true);
> }
>
> void main() {
> auto fooTid = spawn(&foo, thisTid);
> auto receiveInt = receiveTimeout(dur!"seconds"(10), (int isInt) {
> writeln("I should not be here");
> });
> }
> // output: "I should not be here"
> ---
>
> If not, is there some way I could achieve "receiveOnlyTimeout!(int)(dur,
> fun);" ?
>
> Thanks,
> Josh

I am not sure whether it is supposed to be, but the function must be a 
module-level function; so define it outside of main.

When I did that, there was segmentation fault if I used thread priority.

Workaround:

1) Take function out of main

2) Do not specify thread priority

Created bug report:

   http://d.puremagic.com/issues/show_bug.cgi?id=8849

Ali


More information about the Digitalmars-d-learn mailing list