Hi all
I am working on an Interactive Process class. Inside i have a TQueue MessagesToProcess; declared inside header file and i am using this to hold messages that client class wanted to send to other process.
So basically if we have a chance to send a command(if other process is ready), we send it, otherwise queue holds them till time comes.
This is how i add a command to queue
MessagesToProcess.Enqueue(Message);
And this is how i use it inside function SendCommandToProcess
// If there is not a message
if (MessagesToProcess.IsEmpty() == true)
{
return false;
}
....
....
// A string for original message and one for written message
FString WrittenMessage, Message;
MessagesToProcess.Dequeue(Message);
FPlatformProcess::WritePipe(WritePipeParent, Message, &WrittenMessage);
Normally, what should happen is, after Dequeue() is called the received item should be removed from the queue list. However it doesn’t remove it at all. The items added keeps remaining inside queue list, which results in the same commands being sent over and over again.
I am wondering if i am misusing the queue or is there a bug with it?
Thanks in advance.
EDIT: I have tried FString MessagesToProcess;, to see if there is another problem with anything else. Everything worked fine. So yes, i am sure that the problem lies in those lines. Dequeue should remove the returned string, however it doesn’t. So either i am using it the wrong way(which seems like not the case), or there is a bug with it.