On Monday, 23 April 2012 at 02:34:19 UTC, Ali Çehreli wrote:
This works at least with 2.059 on 64-bit Linux:

import std.stdio;
import std.concurrency;
import core.thread;

class Foo
{
    int i;
}

void workerFunc(Tid owner)
{
    receive(
        (shared(Foo) foo) {
            writeln("Before: ", foo.i);
            foo.i = 42;
        });

    owner.send(42);
}

void main (string[] args)
{
    shared foo = new shared(Foo);

    auto worker = spawn(&workerFunc, thisTid);
    worker.send(foo);
    receiveOnly!int();
    writeln("After: ", foo.i);
}

The output:

Before: 0
After: 42

Ali

Ali,

I actually did print out the value being passed successfully. It's just that when I used the queue methods (enqueue and dequeue), it get this error. The queue itself is shared, but none of the methods are expecting a shared value nor do I believe they should.

Casey

Reply via email to