{"id":151905,"date":"2020-08-31T03:05:28","date_gmt":"2020-08-30T19:05:28","guid":{"rendered":"http:\/\/4563.org\/?p=151905"},"modified":"2020-08-31T03:05:28","modified_gmt":"2020-08-30T19:05:28","slug":"c%e7%9a%84-std-atomic-%e6%9c%89%e6%8d%8e%e5%b8%a6%e5%90%8c%e6%ad%a5%e7%9a%84%e6%95%88%e6%9e%9c%e5%90%97%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=151905","title":{"rendered":"C++\u7684 std atomic \u6709\u634e\u5e26\u540c\u6b65\u7684\u6548\u679c\u5417\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  C++\u7684 std atomic \u6709\u634e\u5e26\u540c\u6b65\u7684\u6548\u679c\u5417\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : amiwrong123 <\/span>  <span><i><\/i> 3<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>https:\/\/www.cnblogs.com\/zhao-zongsheng\/p\/9092520.html<\/p>\n<p>atomic \u53ef\u4ee5\u4fdd\u8bc1\u5bf9 atomic \u53d8\u91cf\u7684\u53ef\u89c1\u6027\u3002\u4f46\u60f3\u77e5\u9053\uff0c\u4e00\u4e2a\u7ebf\u7a0b\u5148\u4fee\u6539\u4e86 \u4e00\u4e2a\u666e\u901a\u53d8\u91cf\uff0c\u518d\u4fee\u6539\u4e86 \u4e00\u4e2a atomic \u53d8\u91cf\uff0c\u662f\u5426\u4e5f\u53ef\u4ee5\u4fdd\u8bc1 \u522b\u7684\u7ebf\u7a0b\u53ef\u89c1\u8fd9\u4e2a\u666e\u901a\u53d8\u91cf\u7684\u4fee\u6539\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>6<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3176488\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : teawithlife <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             atomic \u6ca1\u6709\u4fdd\u8bc1\u201c\u53ef\u89c1\u6027\u201d\u8fd9\u4e00\u8bf4\u6cd5\uff0c\u4fdd\u8bc1\u7684\u662f\u64cd\u4f5c\u7684\u539f\u5b50\u6027<br \/>\u53e6\u5916\u6587\u7ae0\u4e2d\u5df2\u7ecf\u591a\u6b21\u63d0\u5230\uff0c\u5728\u4fdd\u8bc1\u8f93\u5165\u8f93\u51fa\u4e00\u81f4\u7684\u60c5\u51b5\u4e0b\uff0cC++\u7f16\u8bd1\u5668\u53ef\u4ee5\u81ea\u884c\u4f18\u5316\u8bed\u53e5\u7684\u6267\u884c\u987a\u5e8f\uff0c\u56e0\u6b64\u4f60\u8bf4\u7684 atomic \u53d8\u91cf\u548c\u666e\u901a\u53d8\u91cf\uff0c\u54ea\u4e2a\u5148\u6539\u53d8\u662f\u65e0\u6cd5\u4fdd\u8bc1\u7684\uff0c\u6240\u4ee5\u65e0\u6cd5\u5b9e\u73b0\u4f60\u8bf4\u7684\u201c\u540c\u6b65\u201d\u6548\u679c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3176489\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : sryanyuan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u9700\u8981\u4f9d\u8d56\u5bf9\u5e94\u539f\u5b50\u53d8\u91cf\u3002<\/p>\n<p>\u9700\u8981\u5728\u7ebf\u7a0b 1 \u4e2d\u4f7f\u7528 memory_order_release \u6765\u5199\u539f\u5b50\u53d8\u91cf\uff0c\u7ebf\u7a0b 2 \u4e2d\u5bf9\u4e8e\u5bf9\u5e94\u7684\u539f\u5b50\u53d8\u91cf\u4f7f\u7528 acquire\uff0c\u5047\u8bbe\u53d1\u73b0\u53d8\u66f4\u4e86\uff0c\u5219\u5373\u53ef\u5bf9\u7ebf\u7a0b 1 \u4e2d\u4fee\u6539\u7684\u666e\u901a\u53d8\u91cf\u53ef\u89c1                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3176490\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Akiyu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u770b\u8d77\u6765\u4f60\u8bf4\u7684\u662f memory order. <br \/>https:\/\/en.cppreference.com\/w\/cpp\/atomic\/memory_order <br \/>https:\/\/gcc.gnu.org\/wiki\/Atomic\/GCCMM\/AtomicSync <\/p>\n<p>\u4f60\u4e0d\u6307\u5b9a\u4efb\u4f55\u53c2\u6570, \u9ed8\u8ba4\u7c7b\u578b\u4e3a Sequentially Consistent . \u65e0\u8bba\u662f\u666e\u901a\u53d8\u91cf, \u8fd8\u662f atomic \u7c7b\u578b\u90fd\u662f\u540c\u6b65\u7684. \u8fd9\u65e0\u9700\u62c5\u5fc3.                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3176491\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : fakeshadow <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u539f\u5b50\u64cd\u4f5c\u7684\u987a\u5e8f\u53ef\u4ee5\u63a7\u5236\u5185\u5b58\u987a\u5e8f \/\u5c4f\u969c\u3002\u5982\u679c\u4e00\u81f4\u6027\u8981\u6c42\u9ad8\u5e76\u4e14\u4e0d\u719f\u6089\u539f\u5b50\u64cd\u4f5c\u8bf7\u5c3d\u91cf\u4f7f\u7528 seqcst \u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3176492\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Akiyu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/stackoverflow.com\/questions\/12346487\/what-do-each-memory-order-mean <br \/>\u518d\u9644\u52a0\u4e00\u4e2a\u66f4\u597d\u7406\u89e3\u7684\u89e3\u91ca                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3176493\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dangyuluo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u4e0d\u5c31\u662f\u6211\u524d\u6bb5\u65f6\u95f4\u7ea0\u7ed3\u8fc7\u7684 Memory order \u4e48                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>C++\u7684 std atomic \u6709&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/151905"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=151905"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/151905\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=151905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=151905"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=151905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}