Are structs saved in multi-thread delegate call?

Ramon via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Apr 22 18:00:10 PDT 2016


I have something along this way:

struct json_value
{
	..
}

function DoDirSearch(..)
{
	immutable json_value cbk = json_value(prms.argv[3]);
	assert(cbk != json_value.init); // OK, pass
	
	import core.thread;
	new Thread({
		assert(cbk != json_value.init); // FAIL!
	}).start();
}

the problem is, my struct value is not saved in the spawned tread 
context, so this assert fails while at the start it passed:

assert(cbk != json_value.init);


More information about the Digitalmars-d-learn mailing list