Files
concurrency-in-action/source/listing_3.10.cpp
2018-10-18 00:40:34 -05:00

30 lines
496 B
C++

#include <mutex>
class Y {
private:
int some_detail;
mutable std::mutex m;
int get_detail() const
{
std::lock_guard<std::mutex> lock_a(m);
return some_detail;
}
public:
Y(int sd) : some_detail(sd) {}
friend bool operator==(Y const& lhs, Y const& rhs)
{
if (&lhs == &rhs)
return true;
int const lhs_value = lhs.get_detail();
int const rhs_value = rhs.get_detail();
return lhs_value == rhs_value;
}
};
int
main()
{
}