sending the address of a struct

Johann Lermer johann.lermer at
Sun Sep 6 09:58:54 UTC 2020


I have a struct in a separate thread and want to pass it's 
address back to the main thread. This is how I think it should 

import std.concurrency;

struct Env {}

void run ()
	shared Env env;
	ownerTid.send (&env);
	for (;;) {}

void main ()
	spawn (&run);
	auto e = receiveOnly!(shared Env*);

but I'm getting an error when main tries to receive the pointer. 
The error message says:

std.concurrency.MessageMismatch at std/concurrency.d(237): 
Unexpected message type: expected 'shared(Env*)', got 

Now, how can I pass that pointer back to main?

More information about the Digitalmars-d-learn mailing list