pass array of objects to spawn

Ruslan Mullakhmetov tiabaldu at gmail.com
Thu Nov 10 13:06:12 PST 2011


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;

class Foo
{

}

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

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


P.S. I do need to create data in main thread and distribute it to child 
threads.

-- 
BR, Ruslan Mullakhmetov



More information about the Digitalmars-d-learn mailing list