You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Something I have recently seen is people removing const from read only functions due to adding a mutex to control access and of course mutex changes state when used.
Example:
// rvo will use the vector move constructor...
std::vector<widget> get() const
{
std::unique_lock<std::mutex> lk(cs_);
std::vector<widget> copy(widgets_);
return copy;
}
// in class definition
mutable std::mutex cs_;
std::vector<widget>widgets_;
The text was updated successfully, but these errors were encountered:
Herb, we should consider a "use mutable when" rule. Sergey, could you please write up a rule about objects that are internally synchronized--mutex, atomic, lock-free queue--and submit it as a PR?
Bjarne suggests need two rules: application for synchronization and when you want a mutable.
Something I have recently seen is people removing
const
from read only functions due to adding a mutex to control access and of course mutex changes state when used.Example:
The text was updated successfully, but these errors were encountered: