My scenario: one server and some clients (although not many). A server can only respond to one client at a time, so they must be in the queue. I use the mutex ( boost::interprocess::interprocess_mutex ) for this, wrapped in boost::interprocess::scoped_lock .
The fact is that if one client dies unexpectedly (i.e. does not start the destructor) while saving the mutex, other clients have problems because they are waiting for this mutex. I examined the use of timeouts, so if a client waits for, say, 20 seconds and does not receive a mutex, he will continue negotiations with the server anyway.
Problems with this approach: 1) he does it every time. If he is in a cycle, constantly talking with the server, he needs to wait for a timeout every time. 2) If there are three clients, and one of them dies, holding the mutex, the other two will wait 20 seconds and simultaneously talk to the server - exactly what I tried to avoid.
So, how can I tell the client: "Hey, it looks like this mutex was abandoned, take responsibility for it"?
c ++ synchronization boost concurrency boost-interprocess
Pedro d'quino
source share