On 2011-11-11 01:21:09 +0400, Ali Çehreli said:

class Foo
{

}

void worker( shared(Foo)[] data )
{
     //...
}

void main()
{
     auto data = new shared(Foo)[10];
     spawn( &worker, data );
}


Thanks. I tried to use the second version, a lttle bit modified it for actual mutation and it is failed to compile with error

thread.d(17): Error: function thread.Foo.mutate () is not callable using argument types () shared


the code:

import std.exception;
import std.concurrency;

class Foo
{
        public int val;
        
        void mutate()
        {
                val = 1;
        }
}


void worker( shared(Foo)[] data )
{
        data[0].mutate();
    //...
}

void main()
{
    auto data = new shared(Foo)[10];
    spawn( &worker, data );
}


--
BR, Ruslan Mullakhmetov

Reply via email to