I'm making a server using Boost asio and I'm facing a problem. My server should be able to receive data from multiple connected clients and to send commands to specific client too.
To do this i'm instantiating a new connection session for each client that connect in which I call async_read with a callback that call async_write with a callback that call async_read etc...
The problem that I'm facing is the following:
A have a GUI for the server in which I can click on commands to send, those commands are then put in a shared queue. As the queue is shared, each connection session can poll to see if there is a command to be send to their connected client.
The problem is, with that "callback that call itself" scheme in the session, how can I check when there is a command for me in the queue without ruining the performance (my first solution was to put a deadline timer on the async_write operation so that I can check each X seconds) ?
Any idea ?