Re: pass array of objects to spawn

2011-11-10 Thread Ruslan Mullakhmetov
On 2011-11-11 02:48:52 +0400, Timon Gehr said: On 11/10/2011 11:00 PM, Ruslan Mullakhmetov wrote: 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 threa

Re: pass array of objects to spawn

2011-11-10 Thread bearophile
Timon Gehr: > Interesting, apparently cast() does not remove shared. The semantics of cast() was never formalized, I think. People use this idiom, so I think we have to formalize what cast() exactly does. This is meat for Bugzilla or even for discussion topic in the main D newsgroup. Generally

Re: pass array of objects to spawn

2011-11-10 Thread Timon Gehr
On 11/10/2011 11:23 PM, Ali Çehreli wrote: On 11/10/2011 01:57 PM, Ruslan Mullakhmetov wrote: 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

Re: pass array of objects to spawn

2011-11-10 Thread Timon Gehr
On 11/10/2011 11:00 PM, Ruslan Mullakhmetov wrote: 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 da

Re: pass array of objects to spawn

2011-11-10 Thread Ali Çehreli
On 11/10/2011 01:57 PM, Ruslan Mullakhmetov wrote: 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 modi

Re: pass array of objects to spawn

2011-11-10 Thread Ruslan Mullakhmetov
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];

Re: pass array of objects to spawn

2011-11-10 Thread Ruslan Mullakhmetov
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 i

Re: pass array of objects to spawn

2011-11-10 Thread Timon Gehr
On 11/10/2011 10:06 PM, Ruslan Mullakhmetov wrote: Hi folks, I need to create thread and pass to it array of objects wich will no longer use in main thread. The problem is that spawn only accepts immutables and i have no idea how to tell him that i transfer full ownership of the data to child t

Re: pass array of objects to spawn

2011-11-10 Thread Ali Çehreli
On 11/10/2011 01:06 PM, Ruslan Mullakhmetov wrote: Hi folks, I need to create thread and pass to it array of objects wich will no longer use in main thread. The problem is that spawn only accepts immutables and i have no idea how to tell him that i transfer full ownership of the data to child t

pass array of objects to spawn

2011-11-10 Thread Ruslan Mullakhmetov
Hi folks, I need to create thread and pass to it array of objects wich will no longer use in main thread. The problem is that spawn only accepts immutables and i have no idea how to tell him that i transfer full ownership of the data to child thread. the code: import std.concurrency