{"id":193,"date":"2021-02-10T10:08:14","date_gmt":"2021-02-10T02:08:14","guid":{"rendered":"http:\/\/gjweb.top\/?p=193"},"modified":"2021-02-10T10:08:15","modified_gmt":"2021-02-10T02:08:15","slug":"node%e5%9f%ba%e7%a1%80%e6%9c%8d%e5%8a%a1%e6%9e%b6%e6%9e%84","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=193","title":{"rendered":"Node\u57fa\u7840\u670d\u52a1\u67b6\u6784"},"content":{"rendered":"\n<ol class=\"wp-block-list\"><li>JS\u5982\u4f55\u8c03\u7528C++<\/li><li>libuv &amp; V8\u7684\u529f\u80fd<\/li><li>Event Loop \u7b80\u5355\u4ecb\u7ecd<\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">1.JS\u5982\u4f55\u8c03\u7528C++<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1.1 Node.js\u662f\u4ec0\u4e48<\/h3>\n\n\n\n<p>\u5b83\u662f\u5c06\u591a\u79cd\u6280\u672f\u7ec4\u5408\u8d77\u6765,\u8ba9JavaScript\u4e5f\u80fd\u8c03\u7528\u7cfb\u7edf\u63a5\u53e3,\u5f00\u53d1\u540e\u7aef\u5e94\u7528.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1.2 Node\u7528\u7684\u4e86\u54ea\u4e9b\u6280\u672f<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>V8\u5f15\u64ce<\/li><li>libuv<\/li><li>C\/C++\u5b9e\u73b0\u7684 c-ares\u3001http-parser\u3001OpenSSL\u3001zlib1.3 \u67b6\u6784\u56fe<\/li><li>bindings<ul><li>node.js\u7528C++\u5bf9http_parser\u8fdb\u884c\u4e86\u5c01\u88c5\uff0c\u662f\u4ed6\u7b26\u5408\u67d0\u4e9b\u8981\u6c42\uff0c\u5c01\u88c5\u7684\u6587\u4ef6\u53eb\u505ahttp_parser_bindings.cpp;\u5e76\u7f16\u8bd1\u6210.node\u6587\u4ef6\uff0c\u4f9b\u7ed9js\u8c03\u7528.<\/li><\/ul><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">2.libuv &amp; V8\u7684\u529f\u80fd<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">2.1 libuv\u662f\u4ec0\u4e48<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>\u4e3a\u4e86\u4e00\u4e2a\u8de8\u5e73\u53f0\u7684\u5f02\u6b65I\/O\u5e93,\u5f00\u59cb\u5199libuv<ul><li>libuv\u4f1a\u6839\u636e\u7cfb\u7edf\u81ea\u52a8\u9009\u62e9\u5408\u9002\u7684\u65b9\u6848<\/li><\/ul><\/li><li>\u529f\u80fd<ul><li>\u53ef\u4ee5\u7528\u4e8eTCP\/UDP\/DNS\/\u6587\u4ef6\u7b49\u5f02\u6b65\u64cd\u4f5c<\/li><\/ul>2.2 V8\u662f\u4ec0\u4e48<\/li><li>\u529f\u80fd<ul><li>\u5c06JS\u5143\u4ee3\u5417\u7f16\u7a0b\u672c\u5730\u4ee3\u7801\u5e76\u6267\u884c<\/li><li>\u7ef4\u62a4\u8c03\u7528\u6808,\u786e\u4fddJS\u51fd\u6570\u7684\u6267\u884c\u4e66\u987a\u5e8f<\/li><li>\u5185\u5b58\u7ba1\u7406,\u4e3a\u6240\u6709\u5bf9\u8c61\u5206\u914d\u5185\u5b58<\/li><li>\u5b9e\u73b0JS\u7684\u6807\u51c6\u5e93<\/li><\/ul><\/li><li>\u6ce8\u610f<ul><li>V8\u4e0d\u63d0\u4f9bDOM API<\/li><li>V8 \u6267\u884cJS\u662f\u5355\u7ebf\u7a0b\u7684<\/li><li>\u53ef\u4ee5\u5f00\u542f\u4e24\u4e2a\u7ebf\u7a0b\u5206\u522b\u6267\u884cJS<\/li><li>V8\u672c\u8eab\u662f\u5305\u542b\u591a\u4e2a\u7ebf\u7a0b\u7684,\u5982\u5783\u573e\u56de\u6536\u4e3a\u5355\u72ec\u7ebf\u7a0b<\/li><li>\u81ea\u5e26event loop \u4f46 Node.js\u57fa\u4e8elibuv\u81ea\u5df1\u505a\u4e86\u4e00\u4e2a<\/li><\/ul><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">3.Event Loop \u7b80\u5355\u4ecb\u7ecd<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">3.1 EVent \u662f\u4ec0\u4e48<\/h3>\n\n\n\n<p>\u7b80\u5355\u7406\u89e3\u6210\u4e8b\u4ef6 \u5206\u4e3a\u5185\u90e8\u4e8b\u4ef6(\u8ba1\u65f6\u5668) \u5916\u90e8\u4e8b\u4ef6(\u6587\u4ef6\u8bfb\u5199\\scoket\u8fde\u63a5)<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3.2 Loop \u662f\u4ec0\u4e48<\/h3>\n\n\n\n<p>\u7b80\u5355\u7406\u89e3\u6210\u5faa\u73af \u7531\u4e8e\u65f6\u95f4\u662f\u5206\u4f18\u5148\u7ea7\u7684,\u6240\u4ee5\u6309\u987a\u5e8f\u5904\u7406; Node\u9700\u8981\u6309\u987a\u5e8f\u8f6e\u8be2\u6bcf\u79cd\u4e8b\u4ef6;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3.3 Event Loop<\/h3>\n\n\n\n<p>\u64cd\u4f5c\u7cfb\u7edf\u53ef\u4ee5\u51fa\u53d1\u4e8b\u4ef6,js\u53bb\u5904\u7406\u4e8b\u4ef6 Event Loop\u5c31\u662f\u5bf9\u65f6\u95f4\u5904\u7406\u987a\u5e8f\u7684\u7ba1\u7406<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Node\u7279\u70b9<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>\u4f18\u70b9<ul><li>\u5f02\u6b65\u975e\u963b\u585eI\/O(I\/O\u7ebf\u7a0b\u6c60)<\/li><li>\u7279\u522b\u9002\u5408I\/O\u5bc6\u96c6\u578b\u5e94\u7528(\u9ad8\u5e76\u53d1)<\/li><li>\u4e8b\u4ef6\u5faa\u73af\u673a\u5236(\u72ec\u6709\u7684\u4e00\u5957,\u5f02\u6b65\u6d4f\u89c8\u5668\u4e0d\u4e00\u6837)<\/li><li>\u5355\u7ebf\u7a0b<\/li><li>\u8de8\u5e73\u53f0<\/li><\/ul><\/li><li>\u4e0d\u8db3<ul><li>\u56de\u8c03\u51fd\u6570\u5d4c\u5957\u592a\u591a(\u56de\u8c03\u5730\u57df)<\/li><li>\u5355\u7ebf\u7a0b,\u5904\u7406\u4e0d\u597dCPU\u5bc6\u96c6\u578b\u4efb\u52a1<\/li><\/ul><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>JS\u5982\u4f55\u8c03\u7528C++ libuv &amp; V8\u7684\u529f\u80fd Event Loop \u7b80\u5355\u4ecb\u7ecd 1.JS\u5982\u4f55\u8c03\u7528C++ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-193","post","type-post","status-publish","format-standard","hentry","category-node"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/193","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=193"}],"version-history":[{"count":0,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/193\/revisions"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}