I'm building an embedded application based on a chat example in boost::asio library. The server receives messages from the client and sends them on an interface which uses pure virtual functions. The response is then recovered from this interface and sent back to the client. I'm unable to get it to multi-thread properly as it crashes at different locations. http://www.boost.org/doc/libs/1_63_0/doc/html/boost_asio/examples.html
I'd like to know if all the shared objects in each class should be declared static, protected by mutex, can I use virtual functions or not. How to modify this server so that it runs one thread for receiving msg on the network, one for sending it on the interface and other to recover response to post back to the client because all of them are asynchronous. The code volume is large, so I don't know how can I post all of this. Any ideas are appreciated. Thanks