{"blog_url":"https://yohhoy.hatenadiary.jp/","author_url":"https://blog.hatena.ne.jp/yohhoy/","author_name":"yohhoy","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fyohhoy.hatenadiary.jp%2Fentry%2F20161106%2Fp1\" title=\"\u306a\u305cmutex\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f\u30e0\u30fc\u30d6\u3067\u304d\u306a\u3044\u304b\uff1f - yohhoy\u306e\u65e5\u8a18\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","provider_name":"Hatena Blog","blog_title":"yohhoy\u306e\u65e5\u8a18","url":"https://yohhoy.hatenadiary.jp/entry/20161106/p1","width":"100%","image_url":null,"categories":["C++"],"version":"1.0","published":"2016-11-06 00:00:00","description":"C++\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u63d0\u4f9b\u3059\u308bstd::mutex\u307b\u304b\u540c\u671f\u30d7\u30ea\u30df\u30c6\u30a3\u30d6\u578b*1\u306f\u3001\u610f\u56f3\u7684\u306b\u30b3\u30d4\u30fc\uff0f\u30e0\u30fc\u30d6\u64cd\u4f5c\u3092\u7981\u6b62\u3057\u3066\u3044\u308b\u3002\u672c\u8a18\u4e8b\u306e\u5185\u5bb9\u306fStack Overflow\u3067\u898b\u3064\u3051\u305f\u8cea\u554f\u3068\u56de\u7b54\u306b\u57fa\u3065\u304f\u3002 #include <mutex> class X { int data_ = 0; std::mutex mtx_; using Lock = std::lock_guard<std::mutex>; public: int get() { Lock lk(mtx_); return data_; } void set(int v) { Lock lk(mtx_); data_ = v; } }; /\u2026","title":"\u306a\u305cmutex\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306f\u30e0\u30fc\u30d6\u3067\u304d\u306a\u3044\u304b\uff1f","height":"190","type":"rich","provider_url":"https://hatena.blog"}