Threads : Push data safely in the threads ?


I am implementing a network manager managing all the data sent and received from my MasterServer. I need it to be in another thread.
That’s not a problem since there is plenty of documentation on that, my problem is that I would like to be able to queue the data I need to parse in another thread.
I have the thread where I receive and send data, manage the socket and the connection itself. Then I have a second thread that “should” receive each message, parse them and do what needs to be done.
My problem is that I am looking for a way to have a queue in the thread that handles the messages and be able to add into this queue from outside the thread.
I am not sure what mechanism UE4 gives us to do that.

I am currently thinking for something in the likes of Singleton class for each thread of course and have a thread-safe static queue to get the data. But I don’t like that and I would prefer being able to call functions from the threads (a way to queue the calls I guess and the thread will handle them whenever).

I actually might have found something that could work :

Best regards,


Use a TQueue maybe?

That’s what I thought at first but with a TQueue I can give something to process but I cannot call any function. For example the player might want to send a message I would liek to call the function sendMessage with the text instead of creating and setting up everything on the graphic thread.