On 2011-11-11 01:23:01 +0400, Timon Gehr said:

class Foo
{

}

void worker( shared(Foo[]) data_ )
{
Foo[] data = cast() data_; // this cast is valid because data_ is never read from another thread after the cast
     //...
}

void main()
{
     {
         auto data = new Foo[10];
spawn( &worker, cast(shared)data ); // this cast is valid because data is an unique reference (therefore there are no unshared aliases) } // the sole reference to data in the main thread dies -> it will never be read from this thread again
}

Thank you too. Unfortunately i got compilation error

thread.d(16): Error: cannot implicitly convert expression (data_) of type shared(Foo)[] to Foo[]



--
BR, Ruslan Mullakhmetov

Reply via email to