{"id":236406,"date":"2020-12-31T06:50:19","date_gmt":"2020-12-30T22:50:19","guid":{"rendered":"http:\/\/4563.org\/?p=236406"},"modified":"2020-12-31T06:50:19","modified_gmt":"2020-12-30T22:50:19","slug":"%e5%ae%9a%e6%97%b6%e7%be%a4%e5%8f%91%e6%8a%a5%e6%96%87%e6%97%b6%ef%bc%8c%e6%80%8e%e4%b9%88%e5%81%9a%e5%a4%9a%e7%ba%bf%e7%a8%8b%e6%af%94%e8%be%83%e4%bc%98%e9%9b%85","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=236406","title":{"rendered":"\u5b9a\u65f6\u7fa4\u53d1\u62a5\u6587\u65f6\uff0c\u600e\u4e48\u505a\u591a\u7ebf\u7a0b\u6bd4\u8f83\u4f18\u96c5?"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5b9a\u65f6\u7fa4\u53d1\u62a5\u6587\u65f6\uff0c\u600e\u4e48\u505a\u591a\u7ebf\u7a0b\u6bd4\u8f83\u4f18\u96c5?               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : auto8888 <\/span>  <span><i><\/i> 6<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u5e94\u7528\u573a\u666f\u662f socket \u901a\u4fe1\uff0c\u4e3b\u7ebf\u7a0b\u7ec4\u5305\uff0c\u6bcf\u79d2\u5b9a\u65f6\u7fa4\u53d1\u591a\u4e2a tcp \u62a5\u6587\uff0c\u5982\u679c\u53d1\u9001\u90fd\u653e\u5728\u4e00\u4e2a\u7ebf\u7a0b\u91cc\uff0c\u6015\u4e2d\u95f4\u6709 TCP \u5835\u585e\uff0c\u5f71\u54cd\u5176\u4ed6\u7684\u53d1\u9001\u3002<\/p>\n<p>\u8fd9\u4e2a\u9700\u6c42\u662f\u4e0d\u662f\u53eb\u53d1\u4ee4\u67aa\uff1f\u4ec0\u4e48 wait()\u3001notify()\u5565\u7684\uff0c\u4f46\u6bcf\u79d2\u90fd\u8981\u53d1\u4ee4\u4e00\u6b21\uff0c\u611f\u89c9\u597d\u50cf\u4e0d\u592a\u50cf<\/p>\n<p>\u73af\u5883\u662f Linux\uff0cc++11,\u7ebf\u7a0b\u7528\u7684 std::thread<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>3<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4679719\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : crclz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528\u4fe1\u53f7\u91cf\u554a\u3002\u4fe1\u53f7\u91cf\u662f\u5173\u4e8e\u751f\u4ea7\u548c\u6d88\u8d39\u7684\u3002<br \/>\u5047\u8bbe N \u4e2a\u7ebf\u7a0b\u8d1f\u8d23\u5b9a\u65f6\u5411 N \u4e2a TCP \u8fde\u63a5\u53d1\u9001\u62a5\u6587\u3002\u6211\u4eec\u79f0\u8fd9 N \u4e2a\u7ebf\u7a0b\u4e3a N \u4e2a worker \u3002<br \/>\u4f60\u8fd9\u4e2a\u6a21\u578b\u5c31\u662f\u751f\u4ea7\u548c\u6d88\u8d39\u201c\u53d1\u62a5\u6587\u6307\u4ee4\u201d\u7684\u3002\u4e3b\u7ebf\u7a0b\u751f\u4ea7\u6307\u4ee4\uff0cworker \u6d88\u8d39\u6307\u4ee4\u3002<\/p>\n<p>\u6bcf\u4e00\u4e2a worker \u90fd\u5177\u6709\u4e00\u4e2a\u4fe1\u53f7\u91cf S\uff0c\u8fd9\u4e2a S \u7684\u610f\u4e49\u662f\u201c\u53d1\u62a5\u6587\u6307\u4ee4\u201d<br \/>\u4e3b\u7ebf\u7a0b\u6bcf\u79d2\u5bf9\u6bcf\u4e00\u4e2a worker \u7684 S \u8fdb\u884c down\uff0c\u610f\u601d\u662f\u751f\u4ea7\u4e00\u4e2a\u53d1\u62a5\u6587\u6307\u4ee4\u3002<br \/>\u540c\u65f6 worker \u7684\u4ee3\u7801\u662f\uff1awhile true { up(S); send(); }\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4679720\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : heyjei <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7b80\u5355\u7684\u505a\u6cd5\u5c31\u662f\uff0cN \u4e2a\u7ebf\u7a0b\u4ece\u5f02\u6b65\u961f\u5217\u91cc\u7ade\u4e89\u53d6\u6570\u636e\uff0c\u8c01\u5148\u53d6\u5230\u6570\u636e\u5c31\u7531\u8c01\u53d6\u53d1\u9001\u8fd9\u4e2a TCP \u5305\uff0c\u4e3b\u7ebf\u7a0b\u53ea\u7ba1\u5f80\u5f02\u6b65\u961f\u5217\u91cc\u6254 TCP \u5305\u3002<\/p>\n<p>\u5982\u679c\u6015\u8fdb\u7a0b\u91cd\u542f\uff0c\u5f02\u6b65\u961f\u5217\u4e22\u6570\u636e\u7684\u8bdd\uff0c\u53ef\u4ee5\u7528 redis \u6765\u505a\u5f02\u6b65\u961f\u5217                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4679721\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : auto8888 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @crclz \u641e\u5b9a\u4e86\uff0c\u5f88\u5e05<\/p>\n<p>\u4fe1\u53f7\u91cf\u7528\u7684 std::mutex \u548c std::condition_variable <\/p>\n<p> ![image.png]( https:\/\/i.loli.net\/2020\/12\/23\/XHubcOW7FgtpoCV.png)                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5b9a\u65f6\u7fa4\u53d1\u62a5\u6587\u65f6\uff0c\u600e\u4e48\u505a\u591a\u7ebf\u7a0b\u6bd4\u8f83\u4f18&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\/236406"}],"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=236406"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/236406\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=236406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=236406"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=236406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}