"Aliases to mutable thread-local data not allowed" when using spawn()

D_Beginner mailsnachhier-privat at yahoo.de
Sun Dec 2 07:47:35 PST 2012


Hi there,

I'm quite new do D, but from what I've seen so far, I really like 
it.
I tried to implement a very basic chatclient that I've written in 
  Go before, and put the logics to send messages in a send() 
function, looking like this:

void send(TcpSocket sock) {
	while(true) {
		write("Message: ");
		auto msg = strip(readln());
		sock.send(msg);
	}
}

Of course I need this function to run concurrently for I have to 
check for answers from the server at the same time. But when I 
try to launch it in an own thread:

spawn(&send, sock);

I get this strange error:

"Error: static assert "Aliases to mutable thread-local data not 
allowed""

Why is that? How can I make my function(s) run concurrently if 
not in that way?

thanks in advance, D_Beginner.


More information about the Digitalmars-d-learn mailing list