I have a udp client which has 2 threads.
The data which is received from socket is put into a queue which is processed by the second thread.
What is the proper way to do this?
Is this correct?
Case 1
char* buffer = new char[1024];
Receive the socket data in buffer
Lock mutex
_queue.push_back(buffer)
signal the waiting thread
Unlock mutex
//In second thread
while(1)
while(queue not empty)
Lock mutex
const char* buf = _queue.front()
_queue.pop();
Unlock mutex
...
Some strtok actions on buf **(This is causing crash)**
...
delete[] buf //Removing this line removes crash
conditional wait