Why is the empty() function in std::queue not thread-safe? (See here.) Shouldn't const functions always be thread-safe, since it's read-only?
Maybe there may be some mutable variable in the class that may get written by the several threads?
Methods that don't modify the data of a class are only thread-safe if the object is never modified by any method. Otherwise a method on another thread could change the object (under a lock, correctly) and calling queue::empty() on your thread without acquiring the lock could lead to a race condition (depending on its implementation).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With