I am building a system where one thread generates commands and sends them to another thread. The commands will never change once they are created. I have marked the values immutable, but I've been struggling to understand the requirements for sharing a variable across threads.

cannot implicitly convert expression (new AppendChatCommand(type, text)) of type data.messages.AppendChatCommand to immutable(AppendChatCommand)


I'm trying to do this:

immutable(AppendChatCommand) command = new AppendChatCommand(type, text); send(childTid, command); //Compiler does not like command if it's not immutable or shared (and I won't be modifying it or using it in this thread)

The commands are generated and send as messages to the child. I will never even use them again in the parent thread. What is the easiest way to do this? Do I need to mark the class somehow?

I can provide a contrived example if necessary.

Reply via email to