After some extensive googling, I can't find a solution to my problem, as I can't even put a name on what I need.
I'm trying to implement in C++ a message queue. I want to have a separate thread continuously polling a message stream and storing the received messages inside a buffer. Then from the main thread I want to call a spin method that trigger the emptying of the buffer. When called, the polling thread should call a callback function passing one element of the buffer at a time, then erasing this element.
One very important requirement for this implementation is speed. I've done it using a class storing the thread, the buffer, the callback pointer and a mutex to protect the buffer read/write operations. I'm thinking avoiding the overhead of a class might be faster, but I have no real idea on haw to pull it off.
Do you have any advice on this implementation ?
Feel free to ask for more info.