{"id":118091,"date":"2026-10-26T07:40:38","date_gmt":"2026-10-25T23:40:38","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/118091.html"},"modified":"2026-10-26T07:40:38","modified_gmt":"2026-10-25T23:40:38","slug":"%e4%bb%bfmuduo%e5%ae%9e%e7%8e%b0%e9%ab%98%e5%b9%b6%e5%8f%91%e6%9c%8d%e5%8a%a1%e5%99%a8-eventloop_timer_wheel%e8%8a%82%e7%82%b91","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/118091.html","title":{"rendered":"\u4effmuduo\u5b9e\u73b0\u9ad8\u5e76\u53d1\u670d\u52a1\u5668\u2014\u2014EventLoop+_timer_wheel\u8282\u70b91"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261025234035-6ade9373463e0.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" width=\"300\" height=\"300\" \/><\/p>\n<p> &#064;bit::Shadow<\/p>\n<p> \u2727(\u2256 \u25e1 \u2256\u273f<\/p>\n<h4>\u76ee\u5f55<\/h4>\n<ul>\n<li>\n<ul>\n<li>2 \u6458\u8981<\/li>\n<li>3 \u6ce8\u91ca<\/li>\n<li>\n<ul>\n<li>3.0 \u903b\u8f91\u56fe<\/li>\n<li>3.1 \u8bb0\u4e8b\u672c<\/li>\n<li>3.2 \u65b0\u77e5\u8bc6<\/li>\n<li>3.3 \u53cd\u601d<\/li>\n<li>3.4 \u56de\u987e<\/li>\n<li>3.5 AI\u8f85\u52a9<\/li>\n<li>3.6 \u8bef\u533a<\/li>\n<li>3.7 \u4e60\u60ef\u517b\u6210<\/li>\n<li>3.8 \u8bbe\u8ba1\u70b9<\/li>\n<\/ul>\n<\/li>\n<li>4 \u67b6\u6784\u603b\u89c8<\/li>\n<li>5 \u5173\u952e\u6d41\u7a0b\u4e0e\u8c03\u7528\u94fe<\/li>\n<li>\n<ul>\n<li>5.1 \u6784\u9020\u4e0e fd \u7f16\u53f7<\/li>\n<li>5.2 Start \u4e09\u6b65\u4e0e revents \u56de\u586b<\/li>\n<li>5.3 HandleEvent \u5206\u53d1\u4e0e timerfd \u7279\u5224<\/li>\n<li>5.4 tick \u4e0e\u8d85\u65f6\u91ca\u653e<\/li>\n<li>5.5 \u6dfb\u52a0\u4e0e\u5237\u65b0<\/li>\n<li>5.6 \u65b0\u94fe\u63a5\u63a5\u5165<\/li>\n<li>5.7 \u7ebf\u7a0b\u8fb9\u754c<\/li>\n<\/ul>\n<\/li>\n<li>6 \u5f00\u53d1\u4e2d\u9047\u5230\u7684\u95ee\u9898<\/li>\n<li>7 \u5176\u4f59\u7ec6\u8282<\/li>\n<li>8 \u603b\u7ed3<\/li>\n<li>9 \u5e38\u89c1\u95ee\u9898<\/li>\n<li>10 \u6807\u7b7e<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>2 \u6458\u8981<\/h3>\n<p>EventLoop_TimeWheel \u662f Channel&#043;Poller&#xff08;epoll \u5c01\u88c5&#xff09;\u4e4b\u4e0a\u628a\u300c\u65f6\u95f4\u8f6e &#043; timerfd\u300d\u5e76\u5165 IO \u5faa\u73af\u7684\u4e00\u7248&#xff1a;\u65b0\u94fe\u63a5 accept \u540e\u767b\u8bb0\u4e00\u4e2a 20 \u79d2\u5b9a\u65f6\u4efb\u52a1&#xff1b;\u8bfb\u5199\u7b49\u5c31\u7eea\u4e8b\u4ef6\u89e6\u53d1 _event_cb() \u65f6\u5237\u65b0\u8be5\u4efb\u52a1\u5728\u8f6e\u76d8\u4e0a\u7684\u4f4d\u7f6e&#xff1b;timerfd \u6bcf\u79d2\u5c31\u7eea\u9a71\u52a8\u8f6e\u76d8\u524d\u8fdb\u4e00\u683c&#xff0c;\u683c\u5b50\u88ab clear() \u65f6 shared_ptr \u8ba1\u6570\u5f52\u96f6\u3001TimerTask \u6790\u6784&#xff0c;\u6790\u6784\u91cc\u6267\u884c\u8d85\u65f6\u56de\u8c03&#xff08;HupCallback\u2192RemAll()&#xff09;\u540e\u518d _timers.erase(id)\u3002\u4ef7\u503c\u5728\u4e8e\u628a\u300c\u8d85\u65f6\u68c0\u6d4b\u300d\u4ece\u4e1a\u52a1\u4ee3\u7801\u642c\u8fdb\u5c31\u7eea\u4e8b\u4ef6&#xff0c;\u4e3b\u5faa\u73af\u4e0d\u5fc5\u81ea\u5df1\u7b97\u65f6\u95f4\u3002<\/p>\n<p>\u4ee3\u7801\u4ed3\u5e93&#xff1a;moduo_project \/ key_nodes \/ EventLoop_TimeWheel<\/p>\n<h3>3 \u6ce8\u91ca<\/h3>\n<h4>3.0 \u903b\u8f91\u56fe<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261025234037-6ade9375b87b5.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>3.1 \u8bb0\u4e8b\u672c<\/h4>\n<p>tcp_svr.cc \u9996\u5757\u7b14\u8bb0&#xff1a;\u76ee\u7684\u4e3a\u300c\u68c0\u6d4b\/\u5237\u65b0\/\u6dfb\u52a0&#xff08;\u65b0&#xff09;\u94fe\u63a5\/\u91ca\u653e\u65e7\u94fe\u63a5&#xff08;\u8d85\u65f6\u65f6\u95f4&#xff09;\u300d&#xff0c;\u843d\u5730\u4e09\u6761\u2014\u2014\u65f6\u95f4\u8f6e\u6bcf\u79d2\u79fb\u52a8\u4e00\u6b21\u3001\u79fb\u81f3\u4f4d\u7f6e\u91ca\u653e\u94fe\u63a5&#xff1b;\u8bfb\/\u5199\u7b49\u4e8b\u4ef6\u5237\u65b0\u6d3b\u8dc3\u5ea6&#xff1b;\u65b0\u94fe\u63a5\u7eb3\u5165\u6d3b\u8dc3\u5ea6\u7ef4\u62a4\u961f\u5217\u3002\u5bf9\u300c\u5982\u4f55\u5728\u4e3b\u7ebf\u7a0b\u7b49\u5f85\u65f6 tick \u524d\u884c\u300d&#xff0c;\u7ed3\u8bba\u662f\u300c\u4e0d\u80fd\u8fd9\u6837\u89e3\u51b3\u56e0\u4e3a\u8fd9\u672c\u8eab\u5c31\u662f\u77db\u76fe\u7684\u300d&#xff0c;\u6539\u7528 timerfd&#xff08;\u5230\u671f\u5373\u53ef\u8bfb\u7684 fd&#xff09;\u3002\u53e6\u4e24\u9879\u53d6\u820d&#xff1a;Poll \u8981\u6539\u6210\u300c\u6bcf\u79d2\u53bb\u8f6e\u8f6c\u65f6\u95f4\u8f6e\u4e0a\u7684\u4efb\u52a1\u300d&#xff1b;eventfd \u4e0d\u5fc5\u7eb3\u5165\u5237\u65b0&#xff0c;\u56e0\u4e3a\u5b83\u53ea\u662f\u5185\u90e8\u901a\u77e5\u673a\u5236&#xff0c;\u800c\u5237\u65b0\u7684\u76ee\u7684\u662f\u300c\u5237\u65b0\u4e0e\u5220\u9664\u300d\u94fe\u63a5\u3002\u672b\u6bb5\u300c\u63a5\u53e3\u4e8c\u6b21\u4f18\u5316\u300d\u6309 A&#xff08;\u5916\u90e8\u6a21\u5757\u600e\u4e48\u7528&#xff09;&#xff0f;B&#xff08;\u63a5\u6536\u65b0\u6a21\u5757\u7684\u5927\u6a21\u5757&#xff09;&#xff0f;C&#xff08;\u88ab\u7eb3\u5165\u7684\u6a21\u5757&#xff09;\u62c6\u5f00&#xff0c;\u8981\u6c42\u9010\u4e2a\u63a5\u53e3\u6838\u5bf9 C \u4e0e B \u7684\u8054\u7cfb\u3002<\/p>\n<h4>3.2 \u65b0\u77e5\u8bc6<\/h4>\n<p>\u5408\u5e76\u4e94\u5904&#xff1a;\u4fdd\u8bc1\u65e5\u5fd7\u7684\u786e\u5b9a\u6027&#xff1b;EPOLLRDHUP \u8868\u793a\u5bf9\u7aef\u5199\u7aef\u5173\u95ed\u3001\u8981\u8bfb\u5b8c\u8bfb\u56de\u8c03&#xff0c;EPOLLHUP \u8868\u793a\u94fe\u63a5\u6302\u8d77\u3001\u53cc\u65b9\u901a\u4fe1\u4e0d\u53ef\u7528\u3001\u8d70 close \u56de\u8c03&#xff08;Channel::HandleEvent() \u5373\u628a\u524d\u8005\u5f52\u5165\u8bfb\u5206\u652f\u3001\u540e\u8005\u4ea4\u7ed9 _close_cb()&#xff09;&#xff1b;abort() \u7528\u4e8e\u7a0b\u5e8f\u65e0\u6cd5\/\u4e0d\u5e94\u7ee7\u7eed\u7684\u4e25\u683c\u903b\u8f91\u9519\u8bef&#xff08;Poller \u6784\u9020\u5931\u8d25\u3001ReadTimerfd\/ReadEventfd \u5931\u8d25\u5904\u90fd\u5728\u7528&#xff09;&#xff1b;strerror(errno) \u628a\u9519\u8bef\u7801\u8bd1\u6210\u53ef\u8bfb\u5b57\u7b26\u4e32&#xff08;Poller::Poll()\u3001ChannelSet()\u3001ReadCallback \u5747\u6709&#xff09;&#xff1b;\u300c\u52ff\u7a77\u7a76&#xff0c;\u627e\u9002\u5f53\u300d\u2014\u2014_event_channel \u53ea\u7ba1 eventfd \u7684\u8bfb\u5199\u4e0e\u56de\u8c03&#xff0c;\u522b\u628a\u5b83\u548c EventLoop::_poller \u5408\u8d77\u6765\u770b\u3002\u53e6\u6709\u300c\u770b\u5b8c\u4e00\u4e2a\u6a21\u5757\u518d\u4e0b\u624b\u5199&#xff0c;\u5343\u4e07\u4e0d\u8981\u63d0\u65e9\u5199\u300d\u3002<\/p>\n<h4>3.3 \u53cd\u601d<\/h4>\n<p>\u653e\u5728 tcp_svr.cc \u7684 bug \u6bb5\u91cc&#xff0c;\u662f\u300c\u5728\u91ca\u653e\u8d44\u6e90\u65f6\u300d\u7684\u4e09\u6761\u81ea\u67e5&#xff1a;\u4e00\u662f\u903b\u8f91\u76ee\u7684\u5148\u843d\u5230\u300c\u8bb0\u4e8b\u672c\u300d&#xff0c;\u660e\u786e\u6280\u672f\u9009\u53d6\u4e0e\u6a21\u5757\u5212\u5206&#xff1b;\u4e8c\u662f\u76d8\u6e05\u8d44\u6e90\u90fd\u6709\u54ea\u4e9b&#xff08;\u5173\u8054\u5728\u4e00\u8d77&#xff09;\u3001\u89e6\u53d1\u9500\u6bc1\u903b\u8f91\u662f\u4ec0\u4e48&#xff0c;\u6ce8\u91ca\u70b9\u660e\u300c\u50cf Hup \u7684\u524d\u63d0\u662f timerfd \u7684\u8bfb\u5c31\u7eea\u53ca\u4e0e\u4e4b\u5173\u8054 _erase\/clear\u300d&#xff0c;\u5e76\u79f0\u8fd9\u662f bug1 \u4ea7\u751f\u7684\u4e3b\u8981\u539f\u56e0&#xff1b;\u4e09\u662f\u65b0\u589e\/\u4f7f\u7528\u9500\u6bc1\u63a5\u53e3\u6765\u5b8c\u6210\u9500\u6bc1\u3002<\/p>\n<h4>3.4 \u56de\u987e<\/h4>\n<p>Channel.hpp&#xff1a;EPOLLIN\/EPOLLOUT \u662f\u5355\u6bd4\u7279\u4f4d&#xff0c;\u6545\u6dfb\u52a0\u7528 |&#061;\u3001\u89e3\u9664\u7528 &amp;&#061; ~\u3001\u5224\u65ad\u7528 &amp;&#xff1b;std::function \u5305\u88c5\u51fa\u7684\u5bf9\u8c61\u8c03\u7528\u65b9\u5f0f\u540c\u4e00\u822c\u51fd\u6570&#xff1b;\u51fd\u6570\u6307\u9488\u8bbe\u7f6e\u300c\u5747\u52a0 &amp;\u300d&#xff1b;_events \u662f\u76d1\u63a7\u96c6\u5408\u3001_revents \u662f\u89e6\u53d1\u7ed3\u679c&#xff1b;EPOLLPRI \u8868\u793a\u6709\u7d27\u6025\u6570\u636e\/\u5e26\u5916\u6570\u636e\u53ef\u8bfb\u3002<\/p>\n<h4>3.5 AI\u8f85\u52a9<\/h4>\n<p>Channel.hpp&#xff1a;\u91cd\u590d\u5b57\u6bb5&#xff08;Set \u7cfb\u5217\u524d\u7684\u7a7a\u503c\u5224\u5b9a&#xff09;\u501f AI \u8865\u5168&#xff0c;\u5199\u6cd5\u4eff\u81ea\u5df1\u90a3\u4efd\u3002SetReadCB \u4fdd\u7559\u4e86\u300c\u9632\u76f8\u540c\u8d4b\u503c\u505a\u4e0d\u5230\u2014\u2014std::function \u65e0 &#061;&#061;&#xff0c;\u65e0\u6cd5\u53ef\u9760\u6bd4\u8f83&#xff0c;\u8df3\u8fc7\u300d&#xff0c;\u53ea\u7559 assert(&#8230; !&#061; nullptr)\u3002<\/p>\n<h4>3.6 \u8bef\u533a<\/h4>\n<p>\u4e24\u5904\u5408\u5e76&#xff1a;unordered_map::find \u5f97\u5230\u7684\u8fed\u4ee3\u5668\u662f\u6574\u4f53\u6982\u5ff5&#xff0c;\u522b\u628a first\/second \u4e0e\u8fed\u4ee3\u5668\u641e\u6df7&#xff1b;unique_ptr \u4e00\u5b9a\u5148\u6784\u9020\u667a\u80fd\u6307\u9488\u81ea\u8eab\u3001\u518d\u51b3\u5b9a\u662f\u5426\u6784\u9020\u6240\u6307\u7c7b\u578b\u2014\u2014EventLoop \u91cc _event_channel \u4e0e _time_wheel \u7684\u5b9e\u9645\u6b21\u5e8f\u7531\u6210\u5458\u58f0\u660e\u987a\u5e8f\u51b3\u5b9a\u3002<\/p>\n<h4>3.7 \u4e60\u60ef\u517b\u6210<\/h4>\n<p>\u8c03 bug \u8981\u8bb0\u65e5\u5fd7\u4e14\u5fc5\u987b\u575a\u6301&#xff0c;\u4f8b\u5982\u300c\u660e\u660e\u53d1\u9001\u4e86\u6570\u636e\u4e3a\u4f55\u662f 0&#xff1f;\u300d\u8fd9\u7c7b\u73b0\u8c61\u5148\u8bb0\u4e0b\u518d\u67e5\u3002<\/p>\n<h4>3.8 \u8bbe\u8ba1\u70b9<\/h4>\n<p>EventLoop.hpp \u7684\u6838\u5fc3\u8bf4\u660e&#xff1a;\u4efb\u52a1\u961f\u5217\u7528 vector \u800c\u975e\u961f\u5217&#xff0c;\u7406\u7531\u662f\u65b9\u4fbf\u7ba1\u7406\u5185\u90e8\u6570\u636e\u3001\u7ed3\u6784\u5f00\u9500\u5176\u6b21&#xff1b;EventLoop \u7ba1\u7684\u662f\u300c\u7ebf\u7a0b\u5355\u4f4d\u5185\u300d\u4e0e\u300c\u4efb\u52a1\u961f\u5217\u300d\u7684\u8c03\u5ea6&#xff0c;\u96c6\u6210 Poller\u3001Channel\u3001_tasks&#xff08;\u4e34\u754c\u8d44\u6e90&#xff09;\u3002\u4e94\u6761\u62c6\u89e3&#xff1a;_thread_id \u6807\u8bc6\u6240\u5c5e\u7ebf\u7a0b&#xff1b;\u56e0\u4e3a Poller \u7684\u5f02\u6b65\u963b\u585e\u4e0e\u901a\u77e5\u624d\u5f15\u5165 eventfd&#xff0c;\u9632\u300c\u672a\u5c31\u7eea\u4e8b\u4ef6\u4e00\u76f4\u963b\u585e\u300d&#xff1b;\u56e0\u4e3a\u6709 _tasks \u5fc5\u987b\u6709 _mutex&#xff1b;\u56e0\u4e3a\u7ef4\u62a4 eventfd \u8bfb\u5199\u624d\u5f15\u5165 Channel&#xff1b;\u5f15\u5165 Poller \u5c31\u662f\u4e3a\u7ba1 fd \u7684 EPOLL \u7cfb\u5217\u3002\u7b2c\u4e09\u6761\u300c\u6682\u65f6\u672a\u7eb3\u5165\u8d85\u65f6\u7ba1\u7406\u6a21\u5757\u300d\u662f\u5f53\u65f6\u7684\u8bb0\u5f55&#xff0c;\u672c\u7248 _time_wheel \u5df2\u662f\u6210\u5458\u3002<\/p>\n<h3>4 \u67b6\u6784\u603b\u89c8<\/h3>\n<p>\u81ea\u5185\u5411\u5916&#xff1a;Channel.hpp \u2192 Poller.hpp \u2192 TimeWheel.hpp&#xff08;\u542b TimerTask&#xff09;\u2192 EventLoop.hpp \u2192 tcp_svr.cc\u3002Channel \u6301 _events\/_revents \u4e0e\u4e94\u4e2a\u56de\u8c03&#xff1b;Poller \u6301 _epfd\u3001epoll_event _fdarr[1024]\u3001unordered_map&lt;int, Channel*&gt; _channels&#xff1b;TimeWheel \u6301 _tick\u3001_capacity\u3001_timers\u3001_wheel\u3001_timerfd\u3001_evtloop\u3001_timer_channel&#xff1b;EventLoop \u6301 _thread_id\u3001_event_fd\u3001_mutex\u3001_tasks\u3001_poller\u3001_event_channel\u3001_time_wheel\u3002<\/p>\n<p>\u6ce8\u91ca\u5bf9 TimeWheel\/TimerTask \u7684\u5b9a\u6027\u662f\u300c\u4e0e EventLoop \u8026\u5408&#xff0c;\u662f\u76ee\u524d\u4e3a\u6b62\u6700\u590d\u6742\u6700\u96be\u7684\u300d&#xff0c;\u7406\u7531\u4e09\u6761&#xff1a;\u56de\u73af\u56de\u8c03\u4e0e\u5404\u6a21\u5757\u517c\u5bb9\u6027&#xff1b;\u8f6e\u76d8\u79fb\u52a8\u8981\u7eb3\u5165 EventLoop \u5185 timerfd \u7684\u76d1\u63a7&#xff08;\u843d\u5728\u6784\u9020\u51fd\u6570&#xff09;&#xff1b;\u4e3a\u65b9\u4fbf\u5916\u90e8\u63a5\u53e3\u628a timerfd \u4e0e EventLoop* \u4e00\u5e76\u653e\u8fdb TimeWheel\u3002<\/p>\n<p>\u4e24\u5904\u300c\u501f\u7528\u73b0\u6210\u8bbe\u65bd\u300d\u8981\u8bb0\u7262\u3002\u5176\u4e00&#xff0c;Channel::Update()\u3001Remove()\u3001IsTimerFd() \u5728 Channel.hpp \u53ea\u6709\u58f0\u660e&#xff0c;\u5b9a\u4e49\u7edf\u4e00\u653e\u5728 EventLoop.hpp \u672b\u5c3e&#xff0c;\u6ce8\u91ca\u5199\u7684\u539f\u56e0\u662f\u300c\u7c7b\u51fd\u6570\u5728\u672c\u7c7b\u7684 }; \u540e\u624d\u5f00\u59cb\u7f16\u8bd1\u300d\u2014\u2014Update() \u8981\u8c03 _loop-&gt;AddMoniter(this)&#xff0c;\u6b64\u523b EventLoop \u5fc5\u987b\u5b8c\u6574\u3002\u5176\u4e8c&#xff0c;TimeWheel \u6784\u9020\u4f53\u5185\u5c31 _timer_channel-&gt;EnableRead()&#xff0c;\u800c\u5b83\u7ecf Update() \u8d70\u5230 AddMoniter()&#xff1b;\u8fd9\u6761\u94fe\u6210\u7acb\u9760 EventLoop \u4e2d _poller \u58f0\u660e\u5728 _time_wheel \u4e4b\u524d\u3001\u5148\u5b8c\u6210\u6784\u9020\u3002<\/p>\n<h3>5 \u5173\u952e\u6d41\u7a0b\u4e0e\u8c03\u7528\u94fe<\/h3>\n<h4>5.1 \u6784\u9020\u4e0e fd \u7f16\u53f7<\/h4>\n<p>main \u4e2d CreateServer(8080) \u5148\u51fa listenfd&#xff08;\u6ce8\u91ca\u8bb0 3&#xff09;&#xff0c;new EventLoop() \u518d\u51fa _epfd&#xff08;\u6ce8\u91ca\u8bb0 4&#xff09;\u4e0e eventfd&#xff08;\u6ce8\u91ca\u8bb0 5&#xff09;&#xff0c;\u65f6\u95f4\u8f6e\u6784\u9020\u91cc CreateTimerfd() \u518d\u62ff\u4e00\u4e2a fd \u5e76\u7acb\u5373\u4ea4\u7ed9 Channel \u7eb3\u5165 epoll\u3002CreateTimerfd() \u7528 CLOCK_MONOTONIC&#xff08;\u4e0d\u53d7\u7cfb\u7edf\u65f6\u95f4\u8df3\u8dc3\u5f71\u54cd&#xff09;&#xff0c;it_value \u4e0e it_interval \u90fd\u8bbe 1 \u79d2&#xff08;\u65c1\u8fb9\u300c\u6bcf 5.1s \u8d85\u65f6\u54cd\u5e94\u5668\u300d\u7684\u6ce8\u91ca\u5df2\u4e0e\u4ee3\u7801\u4e0d\u7b26&#xff09;\u3002Poller \u6784\u9020\u628a _fdarr \u5168\u90e8\u7f6e events&#061;0\u3001data.fd&#061;MAX_EVENTS&#043;1 \u4f5c\u7a7a\u4f4d\u6807\u8bb0&#xff1b;ChannelSet() \u91cc\u7528 ev.data.fd &#061; fd&#xff0c;\u6240\u4ee5 Poll() \u53ea\u80fd\u9760 data.fd \u53cd\u67e5 _channels\u3002<\/p>\n<h4>5.2 Start \u4e09\u6b65\u4e0e revents \u56de\u586b<\/h4>\n<p>EventLoop::Start() \u56fa\u5b9a\u4e09\u6b65&#xff1a;_poller.Poll(&amp;actives)&#xff08;epoll_wait(&#8230;, -1) \u963b\u585e&#xff09;\u2192 \u9010\u4e2a HandleEvent() \u2192 RunAllTask()\u3002Poll() \u91cc\u5148 push_back(it-&gt;second)&#xff0c;\u518d SetRevents(_fdarr[i].events)&#xff1b;\u800c SetRevents() \u672b\u5c3e\u53c8\u8c03 Update()&#xff0c;\u7b49\u4e8e\u6bcf\u4e2a\u5c31\u7eea\u4e8b\u4ef6\u90fd\u5e26\u4e00\u6b21 EPOLL_CTL_MOD\u3002<\/p>\n<h4>5.3 HandleEvent \u5206\u53d1\u4e0e timerfd \u7279\u5224<\/h4>\n<p>\u8bfb\u5206\u652f EPOLLIN|EPOLLRDHUP|EPOLLPRI \u2192 \u5148 _event_cb() \u518d _read_cb()&#xff1b;EPOLLOUT \u2192 _event_cb() \u518d _write_cb()&#xff1b;EPOLLERR \u2192 _err_cb()&#xff1b;EPOLLHUP \u2192 _close_cb()\u3002\u8bfb\u5206\u652f\u91cc\u6709 if(!IsTimerFd()) _event_cb();\u2014\u2014timerfd \u4e0d\u5237\u65b0\u6d3b\u8dc3\u5ea6\u3002\u539f\u6ce8\u91ca\u5148\u81ea\u95ee listenfd \u8981\u4e0d\u8981\u5237\u65b0&#xff0c;\u968f\u5373\u81ea\u7b54&#xff1a;\u5237\u65b0\u6d3b\u8dc3\u5ea6\u7684\u672c\u8d28\u662f\u907f\u514d\u88ab\u91ca\u653e&#xff0c;\u907f\u514d\u88ab\u91ca\u653e\u7684\u672c\u8d28\u662f\u5df2\u88ab\u7eb3\u5165\u65f6\u95f4\u8f6e&#xff0c;\u800c listenfd \u5e76\u672a\u7eb3\u5165\u3002IsTimerFd() \u7684\u5b9e\u73b0\u5c31\u662f Fd() &#061;&#061; _loop-&gt;GetTimerfd()\u3002<\/p>\n<h4>5.4 tick \u4e0e\u8d85\u65f6\u91ca\u653e<\/h4>\n<p>timerfd \u5c31\u7eea \u2192 \u8be5 Channel \u7684 _read_cb \u5373 TimeWheel::OnTime()&#xff1a;\u5148 ReadTimerfd() \u8bfb\u8d70 8 \u5b57\u8282\u8ba1\u6570&#xff08;\u6ce8\u91ca&#xff1a;\u300ctimerfd \u672c\u8d28\u4ecd\u662f\u4e00\u4e2a\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff0c;\u4e0d\u8bfb\u53d6\u6c38\u8fdc\u7ef4\u6301\u5c31\u7eea\u300d&#xff09;&#xff0c;\u518d TickRun()\u3002<\/p>\n<p><span class=\"token comment\">\/\/ TimeWheel.hpp<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">TickRun<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> flag <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">for<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">auto<\/span> <span class=\"token operator\">&amp;<\/span>e <span class=\"token operator\">:<\/span> _wheel<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">(<\/span>_tick <span class=\"token operator\">&#043;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">%<\/span> _capacity<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>e<span class=\"token operator\">-&gt;<\/span><span class=\"token function\">GetCancelAble<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token function\">ERR_LOG<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;TickRun\u90e8\u5206\u5931\u8d25 id:{%ld}&#034;<\/span><span class=\"token punctuation\">,<\/span> e<span class=\"token operator\">-&gt;<\/span><span class=\"token function\">GetId<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> flag<span class=\"token operator\">&#8212;<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token keyword\">continue<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>flag <span class=\"token operator\">&lt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token function\">ERR_LOG<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;TickRun\u90e8\u5206\u5931\u8d25\u4e2a\u6570:{%d}&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&#8211;<\/span>flag<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token keyword\">return<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n    _tick <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span>_tick <span class=\"token operator\">&#043;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">%<\/span> _capacity<span class=\"token punctuation\">;<\/span><br \/>\n    _wheel<span class=\"token punctuation\">[<\/span>_tick<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">clear<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u9884\u68c0\u67e5\u53ea\u8bfb\u4e0d\u6539\u72b6\u6001&#xff1b;\u76ee\u6807\u683c\u5185\u53ea\u8981\u5b58\u5728\u5df2\u53d6\u6d88\u4efb\u52a1&#xff0c;\u672c\u6b21\u76f4\u63a5\u8fd4\u56de\u3001\u8f6e\u76d8\u4e0d\u524d\u8fdb\u3002\u771f\u6b63\u63a8\u8fdb\u540e clear() \u9500\u6bc1\u8be5\u683c\u5168\u90e8 shared_ptr&#xff0c;\u6700\u540e\u4e00\u4e2a\u5f15\u7528\u6d88\u5931\u65f6 ~TimerTask()&#xff1a;_cancel &#061;&#061; false \u624d\u5148 _task_cb()&#xff08;\u793a\u4f8b\u4e2d\u5373 HupCallback&#xff09;&#xff0c;\u6700\u540e _release()&#xff1b;_cancel &#061;&#061; true \u65f6\u53ea\u6253\u65e5\u5fd7\u5e76 return&#xff0c;\u8fde _release() \u90fd\u4e0d\u6267\u884c\u3002<\/p>\n<h4>5.5 \u6dfb\u52a0\u4e0e\u5237\u65b0<\/h4>\n<p><span class=\"token comment\">\/\/ TimeWheel.hpp<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token function\">TimerAdd<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">uint64_t<\/span> id<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">const<\/span> TaskFunc <span class=\"token operator\">&amp;<\/span>cb<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">uint32_t<\/span> delay<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>_timers<span class=\"token punctuation\">.<\/span><span class=\"token function\">find<\/span><span class=\"token punctuation\">(<\/span>id<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">!&#061;<\/span> _timers<span class=\"token punctuation\">.<\/span><span class=\"token function\">end<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token function\">ERR_LOG<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;timers \u5185\u5df2\u7ecf\u6709id:%ld Add\u5931\u8d25&#034;<\/span><span class=\"token punctuation\">,<\/span> id<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token keyword\">return<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n    PtrTask pt <span class=\"token operator\">&#061;<\/span> std<span class=\"token double-colon punctuation\">::<\/span><span class=\"token generic-function\"><span class=\"token function\">make_shared<\/span><span class=\"token generic class-name\"><span class=\"token operator\">&lt;<\/span>TimerTask<span class=\"token operator\">&gt;<\/span><\/span><\/span><span class=\"token punctuation\">(<\/span>id<span class=\"token punctuation\">,<\/span> cb<span class=\"token punctuation\">,<\/span> delay<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    pt<span class=\"token operator\">-&gt;<\/span><span class=\"token function\">SetCancel<\/span><span class=\"token punctuation\">(<\/span><span class=\"token boolean\">false<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>                                  <span class=\"token comment\">\/\/ BUG2<\/span><br \/>\n    pt<span class=\"token operator\">-&gt;<\/span><span class=\"token function\">SetRealese<\/span><span class=\"token punctuation\">(<\/span>std<span class=\"token double-colon punctuation\">::<\/span><span class=\"token function\">bind<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">&amp;<\/span>TimeWheel<span class=\"token double-colon punctuation\">::<\/span>RemoveTimer<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">,<\/span> id<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    _wheel<span class=\"token punctuation\">[<\/span>delay<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">insert<\/span><span class=\"token punctuation\">(<\/span>_wheel<span class=\"token punctuation\">[<\/span>delay<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">begin<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> pt<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    WeakTask <span class=\"token function\">wp<\/span><span class=\"token punctuation\">(<\/span>pt<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    _timers<span class=\"token punctuation\">[<\/span>id<span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> wp<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u987a\u5e8f\u6709\u4f9d\u8d56&#xff1a;SetRealese() \u5728 _cancel &#061;&#061; true \u65f6\u76f4\u63a5\u62d2\u7edd&#xff0c;\u5fc5\u987b\u5148 SetCancel(false)\u3002\u5237\u65b0\u4e0d\u662f\u6539\u65f6\u95f4\u800c\u662f\u518d\u63d2\u4e00\u4efd&#xff1a;Refresh() \u7528 _timers[id].lock() \u53d6\u56de shared_ptr&#xff0c;\u6309 pos &#061; (GetTimeOut() &#043; _tick) % _capacity \u63d2\u5230\u8f6e\u9996&#xff1b;\u539f\u4f4d\u7f6e\u4ecd\u7559\u65e7\u5f15\u7528&#xff0c;clear() \u53ea\u51cf\u8ba1\u6570\u4e0d\u6790\u6784&#xff0c;\u6790\u6784\u53d1\u751f\u5728\u65b0\u4f4d\u7f6e\u88ab\u6e05\u7a7a\u90a3\u6b21&#xff0c;_timers \u4e2d\u59cb\u7ec8\u53ea\u6709\u4e00\u4efd weak_ptr&#xff0c;\u6545 RemoveTimer \u53ea erase \u4e00\u6b21\u3002RefreshTimerTask \u7684\u6ce8\u91ca\u300c\u600e\u4e48\u4e00\u76f4\u8c03\u7528&#xff1f;\u4e14\u4e0d\u4f1a\u6790\u6784\u300d\u6b63\u6307\u6b64\u4e8b&#xff1a;\u5f15\u7528\u672a\u8017\u5c3d\u524d\u4efb\u52a1\u4e0d\u4f1a\u6267\u884c\u3002<\/p>\n<h4>5.6 \u65b0\u94fe\u63a5\u63a5\u5165<\/h4>\n<p>Acceptor \u5728 accept \u540e new Channel\u3001EnableRead()\u3001\u88c5\u4e94\u4e2a\u56de\u8c03\u3001AddMoniter()&#xff0c;\u6700\u540e AddTimerTask(id, bind(HupCallback, newcli, evtloop, id), 20)&#xff1b;id \u53d6 rand() % 10000 &#043; 30&#xff0c;main \u91cc srand(time(nullptr))\u3002_wheel[delay] \u672a\u53d6\u6a21&#xff0c;\u6545 delay \u5fc5\u987b\u5c0f\u4e8e _capacity(60)\u3002\u6ce8\u610f EnableRead() \u5df2 Update() \u4e00\u6b21 EPOLL_CTL_ADD&#xff0c;\u7d27\u968f\u5176\u540e\u7684 AddMoniter() \u53c8\u8d70\u4e00\u6b21 MOD\u3002<\/p>\n<h4>5.7 \u7ebf\u7a0b\u8fb9\u754c<\/h4>\n<p>TimeWheel::AddTask\/RefreshTask\/CancelTask \u53ea\u628a TimerAdd\/Refresh\/SetCanCel \u5305\u6210 Functor \u4ea4\u7ed9 PushTaskqueue()&#xff1a;\u540c\u7ebf\u7a0b&#xff08;IsMatchEtLoop()&#xff09;\u76f4\u63a5\u6267\u884c&#xff0c;\u5426\u5219 Push() \u5165 _tasks \u540e WeakUpEventfd()\u3002RunAllTask() \u7528 _tasks.swap(tmpFuncs) \u5728\u9501\u5185\u6362\u51fa\u3001\u9501\u5916\u6267\u884c&#xff0c;\u907f\u514d\u6301\u9501\u8dd1\u7528\u6237\u56de\u8c03\u3002<\/p>\n<h3>6 \u5f00\u53d1\u4e2d\u9047\u5230\u7684\u95ee\u9898<\/h3>\n<p>6.1 \u4e0d\u80fd\u5bf9\u65f6\u95f4\u8f6e\u4efb\u52a1 Cancel&#xff08;tcp_svr.cc bug1&#xff09; \u73b0\u8c61\u662f Segment fault\u3002\u539f\u56e0\u6309\u6ce8\u91ca&#xff1a;HupCallback \u672c\u8eab\u5c31\u662f\u65f6\u95f4\u8f6e\u5230\u671f&#xff08;timerfd \u8bfb\u5c31\u7eea\u9a71\u52a8\u3001clear() \u89e6\u53d1\u6790\u6784&#xff09;\u65f6\u6267\u884c\u7684&#xff0c;\u300c\u5982\u679c CancelTimerTask \u5c31\u76f8\u5f53\u4e8e\u5bf9\u5df2\u7ecf\u6790\u6784\u7684\u6210\u5458\u8bbe\u7f6e&#xff0c;\u81ea\u7136\u5bfc\u81f4\u6bb5\u9519\u8bef\u300d\u3002\u5904\u7406\u662f\u628a HupCallback \u4e2d\u90a3\u884c evtloop-&gt;CancelTimerTask(id) \u6ce8\u91ca\u6389\u3002<\/p>\n<p>6.2 \u6dfb\u52a0\u4efb\u52a1\u5fd8\u8bbe _cancel&#xff08;TimeWheel.hpp BUG2 \/ tcp_svr.cc \u6ce8\u91ca\u7b2c 2 \u6761&#xff09; \u5e26\u53c2\u6784\u9020\u7ed9 _cancel(true)&#xff0c;\u800c\u6790\u6784\u53ea\u5728 _cancel &#061;&#061; false \u65f6\u6267\u884c _task_cb() \u4e0e _release()&#xff0c;GetTimeOut() \u5728\u53d6\u6d88\u6001\u8fd8\u76f4\u63a5\u8fd4\u56de 0\u3002\u6545 TimerAdd \u5fc5\u987b\u8865 pt-&gt;SetCancel(false)\u3002<\/p>\n<p>6.3 \u53ea\u8bbe\u5185\u6838\u3001\u6f0f\u8bb0\u6210\u5458&#xff08;Poller.hpp bug1&#xff09; ChannelSet() \u91cc epoll_ctl \u4e4b\u540e\u5fd8\u4e86 _channels[fd] &#061; channel;&#xff0c;\u4e8e\u662f HashAble() \u6052\u5047\u3001UpdateEvent() \u53cd\u590d\u8d70 ADD&#xff0c;Poll() \u91cc find \u76f4\u63a5\u5230 end&#xff0c;\u6253\u5370 Poller::Poll failed \u540e\u8fd4\u56de\u3002\u4fee\u590d\u5373\u5728\u672b\u5c3e\u8865\u8fd9\u4e00\u884c\u3002<\/p>\n<p>6.4 \u7528\u4e86\u5df2\u9500\u6bc1\u7684\u6210\u5458&#xff0c;\u8017 4h&#xff08;Poller.hpp bug2&#xff09; \u6ce8\u91ca\u539f\u6587&#xff1a;\u300c\u6d4b\u8bd5\u65f6\u5ffd\u7565\u6210\u5458\u751f\u547d\u5468\u671f&#xff0c;\u4e8e\u4e0b\u4e00\u8f6e\u5faa\u73af\u4ecd\u4f7f\u7528\u5df2\u9500\u6bc1\u7684\u6210\u5458\u3002\u300d\u5b9a\u4f4d\u9760 ~Channel() \u7684\u65e5\u5fd7&#xff08;\u300c\u826f\u597d\u7684\u7f16\u7a0b\u4e60\u60ef\u300d\u88ab\u5217\u4e3a\u53d1\u6325\u6781\u5927\u4f5c\u7528\u7684\u4e00\u6761&#xff09;&#xff1b;\u8c03\u8bd5\u6280\u5de7\u662f\u300c\u9047\u5230\u641e\u4e0d\u660e\u767d\u7684\u73b0\u8c61\u5148\u8bb0\u5f55\u4e0b\u6765\u518d\u601d\u8003\u300d&#xff0c;\u672c\u8d28\u662f\u4e32\u8054\u8bc1\u636e\u94fe&#xff1b;\u53e6\u8bb0 gdb \u91cc fd \u81ea 10 \u5f00\u59cb\u521b\u5efa\u3001\u5e76\u975e 3&#xff0c;\u4e0d\u5fc5\u5947\u602a\u3002<\/p>\n<p>6.5 Poll \u5185\u6f0f SetRevents&#xff08;Poller.hpp bug3&#xff09; epoll_wait \u8fd4\u56de\u4e86&#xff0c;HandleEvent() \u5374\u770b\u4e0d\u5230 _revents\u3002\u6839\u56e0\u662f\u628a\u300c\u5173\u5fc3\u300d\u4e0e\u300c\u56de\u5e94\u300d\u8bb0\u6df7&#xff1a;epoll_ctl \u8bbe\u7684\u662f\u5173\u5fc3&#xff0c;epoll_wait \u8f93\u51fa\u7684 events \u624d\u662f\u56de\u5e94&#xff0c;\u6ce8\u91ca\u5199\u300c\u672c bug \u4ea7\u751f\u7684\u539f\u56e0\u662f\u5bf9\u77e5\u8bc6\u5fd8\u8bb0\u4e86\u300d\u3002\u4fee\u590d\u5373 it-&gt;second-&gt;SetRevents(_fdarr[i].events)\u3002<\/p>\n<p>6.6 _capacity \u5fc5\u987b\u5b9a\u4e49\u5728 _wheel \u4e4b\u524d&#xff08;TimeWheel.hpp bug1&#xff09; _wheel(_capacity) \u4f9d\u8d56 _capacity \u5df2\u4e3a 60&#xff1b;\u58f0\u660e\u5e8f _capacity\u2192_wheel\u3001\u521d\u59cb\u5316\u5217\u8868\u5e8f _capacity(60), _wheel(_capacity)&#xff0c;\u4e24\u5904\u4e00\u81f4\u624d\u62ff\u5230 60&#xff0c;\u6ce8\u91ca\u8bb0 gdb \u4e5f\u5224\u65ad\u4e0d\u51fa\u521d\u59cb\u5316\u987a\u5e8f\u3002\u3010\u5f85\u6211\u8865\u5145&#xff1a;\u6ce8\u91ca\u5199\u4e86\u300c\u89e3\u51b3\u529e\u6cd5\u6709\u4e24\u79cd\u300d&#xff0c;\u53ea\u8bb0\u4e0b\u4e00\u79cd\u3011<\/p>\n<p>6.7 \u91ca\u653e\u7528 erase \u4e0d\u7528 clear&#xff08;TimeWheel.hpp bug3&#xff09; \u6ce8\u91ca&#xff1a;\u300c\u5e94\u8be5\u7528 erase\u2014\u2014AI\u300d&#xff0c;\u5e76\u6807\u6ce8 _timers.clear() \u662f\u300c\u5c06\u6574\u4e2a timers \u6e05\u7a7a\u300d\u3002RemoveTimer \u662f\u6bcf\u4e2a\u4efb\u52a1\u7684 _release&#xff0c;\u6bcf\u6790\u6784\u4e00\u6b21\u5c31\u8c03\u4e00\u6b21&#xff0c;\u5199\u6210 clear() \u4f1a\u8fde\u5e26\u6e05\u6389\u5176\u5b83\u4efb\u52a1\u7684\u7d22\u5f15\u3002<\/p>\n<p>6.8 \u8f6e\u76d8\u7528\u300c\u8ddd\u79bb\u300d\u8bbf\u95ee&#xff08;TimeWheel.hpp bug4&#xff09; \u6ce8\u91ca&#xff1a;\u300cwheel \u7528\u7684\u662f\u8ddd\u79bb\u8bbf\u95ee\u300d\u3002\u6240\u4ee5 SetCanCel(id) \u4e0d\u80fd\u5199 _wheel[id]&#xff08;id \u662f\u4efb\u52a1\u53f7&#xff0c;_wheel \u4e0b\u6807\u662f\u6ef4\u7b54\u4f4d\u7f6e&#xff09;&#xff0c;\u987b\u5148 uint32_t pos &#061; _timers[id].lock()-&gt;GetTimeOut(); \u518d\u904d\u5386 _wheel[pos]\u3002\u9644\u5e26\u4e24\u70b9&#xff1a;\u8fd9\u884c\u6ca1\u6709 find \u4e0e lock() \u5224\u7a7a&#xff1b;\u5faa\u73af\u662f\u5bf9\u8be5\u683c\u5185\u6240\u6709\u4efb\u52a1 SetCancel(true)&#xff0c;\u800c\u975e\u53ea\u9488\u5bf9 id\u3002<\/p>\n<p>6.9 TickRun \u91cc\u4e0d\u80fd SetCancel(true)&#xff08;TimeWheel.hpp bug5&#xff09; \u6ce8\u91ca\u5728 \/\/ if (!e-&gt;SetCancel (true))\u53ef\u4ee5\u5417&#xff1f; bug5 \u4e0d\u53ef\u4ee5&#xff01;&#xff01; \u5904\u53ea\u7ed9\u7ed3\u8bba&#xff0c;\u4ee3\u7801\u4fdd\u7559\u53ea\u8bfb\u5224\u65ad GetCancelAble()\u3002\u3010\u5f85\u6211\u8865\u5145&#xff1a;\u6ce8\u91ca\u672a\u8bb0\u5f55\u300c\u4e0d\u53ef\u4ee5\u300d\u7684\u5177\u4f53\u540e\u679c\u3011<\/p>\n<p>6.10 \u6210\u5458\u51fd\u6570\u6307\u9488\u5fc5\u987b &amp;\u7c7b\u540d::\u51fd\u6570\u540d&#xff08;EventLoop.hpp bug1&#xff09; std::bind(ReadEventfd, this) \u4e0e std::bind(EventLoop::ReadEventfd, this) \u90fd\u8fc7\u4e0d\u53bb&#xff0c;gcc \u65e0\u6cd5\u5b9a\u4f4d ReadEventfd \u7684\u300c\u4f4d\u7f6e\u300d&#xff1b;\u6b63\u786e\u5199\u6cd5 std::bind(&amp;EventLoop::ReadEventfd, this)\u3002<\/p>\n<h3>7 \u5176\u4f59\u7ec6\u8282<\/h3>\n<ul>\n<li>~Channel() \u5148 _fd &#061; -1 \u518d WRN_LOG(&#034;Channel\u5df2\u7ecf\u6790\u6784fd&#xff1a;%d&#034;, _fd)&#xff0c;\u65e5\u5fd7\u6c38\u8fdc\u662f -1\u3002<\/li>\n<li>RemAll() \u7528 Update() \u800c\u975e Remove()&#xff08;\u6ce8\u91ca\u5df2\u6807&#xff09;&#xff0c;\u6545 fd \u4ecd\u7559\u5728 _channels&#xff0c;\u53ea\u662f\u4e0d\u518d\u5173\u5fc3\u4efb\u4f55\u4e8b\u4ef6\u3002<\/li>\n<li>Poll() \u4e2d find \u5931\u8d25\u8d70 return \u800c\u975e continue&#xff0c;\u672c\u6b21 epoll_wait \u5269\u4f59\u5c31\u7eea fd \u4e00\u5e76\u4e22\u5f03\u3002<\/li>\n<li>TimerAdd \u6309 _wheel[delay] \u653e\u7f6e&#xff0c;Refresh \u6309 (timeout&#043;tick)%capacity \u653e\u7f6e&#xff0c;\u800c SetCanCel \u53c8\u7528 GetTimeOut() \u5f53\u4f4d\u7f6e\u2014\u2014\u4e09\u5904\u53e3\u5f84\u4e0d\u5b8c\u5168\u4e00\u81f4&#xff0c;\u91cd\u5b9a\u4f4d\u8fc7\u7684\u4efb\u52a1\u7528 SetCanCel \u53ef\u80fd\u53d6\u4e0d\u5230\u771f\u6b63\u90a3\u4efd\u3002<\/li>\n<li>HupCallback \u53ea RemAll()&#xff1b;Acceptor \u91cc new \u51fa\u7684 Channel \u5168\u7bc7\u6ca1\u6709 delete\u3002<\/li>\n<\/ul>\n<h3>8 \u603b\u7ed3<\/h3>\n<p>\u9aa8\u67b6&#xff1a;Channel \u5b9a\u300c\u4e00\u4e2a fd \u5173\u5fc3\u4ec0\u4e48\u3001\u5c31\u7eea\u540e\u6309\u4ec0\u4e48\u987a\u5e8f\u56de\u8c03\u300d&#xff0c;Poller \u7ba1\u300c\u628a\u5173\u5fc3\u4ea4\u7ed9\u5185\u6838\u3001\u628a\u56de\u5e94\u53d6\u56de\u6765\u300d&#xff0c;TimeWheel \u7528 timerfd \u628a\u65f6\u95f4\u53d8\u6210\u53ef\u8bfb\u4e8b\u4ef6\u3001\u7528\u8f6e\u76d8\u4f4d\u7f6e\u8868\u8fbe\u5ef6\u8fdf\u3001\u7528 shared_ptr \u6790\u6784\u89e6\u53d1\u8d85\u65f6&#xff0c;EventLoop \u5728\u7ebf\u7a0b\u5185\u4e32\u8d77\u4e09\u8005\u5e76\u63a5\u4f4f\u8de8\u7ebf\u7a0b\u4efb\u52a1\u3002\u6700\u8be5\u8bb0\u4f4f\u4e24\u70b9&#xff1a;\u5237\u65b0\u662f\u300c\u518d\u63d2\u4e00\u4efd shared_ptr\u300d\u800c\u975e\u6539\u5b57\u6bb5&#xff1b;\u8d85\u65f6\u6267\u884c\u5199\u5728\u6790\u6784\u91cc&#xff0c;\u6240\u4ee5 _cancel \u72b6\u6001\u3001_release \u7ed1\u5b9a\u3001erase \u8bed\u4e49\u5fc5\u987b\u540c\u65f6\u6b63\u786e\u3002\u5751\u96c6\u4e2d\u5728\u4e09\u5904\u2014\u2014\u72b6\u6001\u4f4d\u5fd8\u8bbe\u3001epoll\u300c\u5173\u5fc3\/\u56de\u5e94\u300d\u6df7\u6dc6\u3001\u6210\u5458\u751f\u547d\u5468\u671f\u4e0e\u521d\u59cb\u5316\u987a\u5e8f\u3002<\/p>\n<h3>9 \u5e38\u89c1\u95ee\u9898<\/h3>\n<li>HupCallback \u91cc\u90a3\u884c CancelTimerTask \u4e3a\u4f55\u5fc5\u987b\u6ce8\u91ca&#xff1f; \u8be5\u56de\u8c03\u672c\u8eab\u7531 ~TimerTask() \u5728\u8f6e\u76d8 clear() \u65f6\u6267\u884c&#xff0c;\u518d\u53d6\u6d88\u540c\u4e00\u6761\u4efb\u52a1\u7b49\u4e8e\u5bf9\u5df2\u6790\u6784\u6210\u5458\u8bbe\u72b6\u6001&#xff08;\u00a76.1&#xff09;\u3002<\/li>\n<li>Refresh() \u540e\u4e3a\u4f55\u4e0d\u4f1a\u6267\u884c\u4e24\u6b21&#xff1f; _timers \u53ea\u6709\u4e00\u4efd weak_ptr&#xff0c;\u8f6e\u76d8\u591a\u4efd shared_ptr \u6307\u5411\u540c\u4e00 TimerTask&#xff0c;~TimerTask() \u53ea\u5728\u6700\u540e\u4e00\u4e2a\u5f15\u7528\u91ca\u653e\u65f6\u6267\u884c\u4e00\u6b21&#xff08;\u00a75.5&#xff09;\u3002<\/li>\n<li>timerfd \u7684 Channel \u4e3a\u4f55\u8df3\u8fc7 _event_cb()&#xff1f; IsTimerFd() \u4e3a\u771f\u5373\u8df3\u8fc7&#xff1b;\u5b83\u672a\u7eb3\u5165\u65f6\u95f4\u8f6e&#xff0c;\u5237\u65b0\u65e0\u610f\u4e49&#xff0c;\u5176 _read_cb \u662f OnTime()&#xff0c;\u81ea\u5df1\u8bfb\u8ba1\u6570\u518d TickRun()&#xff08;\u00a75.3&#xff09;\u3002<\/li>\n<li>SetCancel() \u4f55\u65f6\u8fd4\u56de false&#xff1f; b &#061;&#061; _cancel \u65f6\u3002TimerAdd \u91cc SetCancel(false) \u56e0\u6784\u9020\u5df2\u7f6e true \u624d\u6210\u529f&#xff1b;SetCanCel \u5bf9\u5df2\u53d6\u6d88\u4efb\u52a1\u518d\u7f6e true \u4f1a\u8fd4\u56de false \u5e76\u6253\u300cSetCanCel\u5931\u8d25\u300d\u3002<\/li>\n<li>Channel::Update() \u4e3a\u4f55\u653e\u5230 EventLoop.hpp \u672b\u5c3e&#xff1f; Channel.hpp \u53ea\u6709\u58f0\u660e&#xff0c;Update() \u8981\u8c03 _loop-&gt;AddMoniter(this)&#xff0c;\u987b\u7b49 EventLoop \u5b8c\u6574&#xff08;\u00a74&#xff09;\u3002<\/li>\n<h3>10 \u6807\u7b7e<\/h3>\n<p>C&#043;&#043; epoll \u65f6\u95f4\u8f6e timerfd EventLoop<\/p>\n<p>\u3010\u7edf\u8ba1&#xff1a;\u5168\u6587\u7ea6 4,5xx \u5b57 \/ \u539f\u4ee3\u7801 944 \u884c \/ \u6bd4\u4f8b \u22484.8&#xff1b;\u6ce8\u91ca\u5b57\u6bb5\u5c0f\u8282 8 \u4e2a \/ \u6210\u6587 bug 10 \u5904\u3011<\/p>\n","protected":false},"excerpt":{"rendered":"<p>bit::Shadow\u2727(\u2256 \u25e1 \u2256\u273f\u76ee\u5f552 \u6458\u89813 \u6ce8\u91ca3.0 \u903b\u8f91\u56fe3.1 \u8bb0\u4e8b\u672c3.2 \u65b0\u77e5\u8bc63.3 \u53cd\u601d3.4 \u56de\u987e3.5 AI\u8f85\u52a93.6 \u8bef\u533a3.7 \u4e60\u60ef\u517b\u62103.8 \u8bbe\u8ba1\u70b94 \u67b6\u6784\u603b\u89c85 \u5173\u952e\u6d41\u7a0b\u4e0e\u8c03\u7528\u94fe5.1 \u6784\u9020\u4e0e fd \u7f16\u53f75.2 Start \u4e09\u6b65\u4e0e revents \u56de\u586b5.3 HandleEvent \u5206\u53d1\u4e0e timerfd \u7279\u52245.4 tick \u4e0e\u8d85\u65f6\u91ca\u653e5.5 \u6dfb\u52a0\u4e0e\u5237\u65b05.6 \u65b0\u94fe\u63a5\u63a5\u51655.7 \u7ebf\u7a0b\u8fb9\u754c6 \u5f00\u53d1\u4e2d\u9047\u5230\u7684\u95ee\u98987 \u5176\u4f59\u7ec6\u82828 \u603b\u7ed39 \u5e38\u89c1\u95ee\u9898<\/p>\n","protected":false},"author":2,"featured_media":118089,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[868,55,43],"topic":[],"class_list":["post-118091","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-868","tag-c","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4effmuduo\u5b9e\u73b0\u9ad8\u5e76\u53d1\u670d\u52a1\u5668\u2014\u2014EventLoop+_timer_wheel\u8282\u70b91 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/118091.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4effmuduo\u5b9e\u73b0\u9ad8\u5e76\u53d1\u670d\u52a1\u5668\u2014\u2014EventLoop+_timer_wheel\u8282\u70b91 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"bit::Shadow\u2727(\u2256 \u25e1 \u2256\u273f\u76ee\u5f552 \u6458\u89813 \u6ce8\u91ca3.0 \u903b\u8f91\u56fe3.1 \u8bb0\u4e8b\u672c3.2 \u65b0\u77e5\u8bc63.3 \u53cd\u601d3.4 \u56de\u987e3.5 AI\u8f85\u52a93.6 \u8bef\u533a3.7 \u4e60\u60ef\u517b\u62103.8 \u8bbe\u8ba1\u70b94 \u67b6\u6784\u603b\u89c85 \u5173\u952e\u6d41\u7a0b\u4e0e\u8c03\u7528\u94fe5.1 \u6784\u9020\u4e0e fd \u7f16\u53f75.2 Start \u4e09\u6b65\u4e0e revents \u56de\u586b5.3 HandleEvent \u5206\u53d1\u4e0e timerfd \u7279\u52245.4 tick \u4e0e\u8d85\u65f6\u91ca\u653e5.5 \u6dfb\u52a0\u4e0e\u5237\u65b05.6 \u65b0\u94fe\u63a5\u63a5\u51655.7 \u7ebf\u7a0b\u8fb9\u754c6 \u5f00\u53d1\u4e2d\u9047\u5230\u7684\u95ee\u98987 \u5176\u4f59\u7ec6\u82828 \u603b\u7ed39 \u5e38\u89c1\u95ee\u9898\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/118091.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-25T23:40:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261025234035-6ade9373463e0.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/118091.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/118091.html\",\"name\":\"\u4effmuduo\u5b9e\u73b0\u9ad8\u5e76\u53d1\u670d\u52a1\u5668\u2014\u2014EventLoop+_timer_wheel\u8282\u70b91 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-25T23:40:38+00:00\",\"dateModified\":\"2026-10-25T23:40:38+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/118091.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/118091.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/118091.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4effmuduo\u5b9e\u73b0\u9ad8\u5e76\u53d1\u670d\u52a1\u5668\u2014\u2014EventLoop+_timer_wheel\u8282\u70b91\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4effmuduo\u5b9e\u73b0\u9ad8\u5e76\u53d1\u670d\u52a1\u5668\u2014\u2014EventLoop+_timer_wheel\u8282\u70b91 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/118091.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4effmuduo\u5b9e\u73b0\u9ad8\u5e76\u53d1\u670d\u52a1\u5668\u2014\u2014EventLoop+_timer_wheel\u8282\u70b91 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"bit::Shadow\u2727(\u2256 \u25e1 \u2256\u273f\u76ee\u5f552 \u6458\u89813 \u6ce8\u91ca3.0 \u903b\u8f91\u56fe3.1 \u8bb0\u4e8b\u672c3.2 \u65b0\u77e5\u8bc63.3 \u53cd\u601d3.4 \u56de\u987e3.5 AI\u8f85\u52a93.6 \u8bef\u533a3.7 \u4e60\u60ef\u517b\u62103.8 \u8bbe\u8ba1\u70b94 \u67b6\u6784\u603b\u89c85 \u5173\u952e\u6d41\u7a0b\u4e0e\u8c03\u7528\u94fe5.1 \u6784\u9020\u4e0e fd \u7f16\u53f75.2 Start \u4e09\u6b65\u4e0e revents \u56de\u586b5.3 HandleEvent \u5206\u53d1\u4e0e timerfd \u7279\u52245.4 tick \u4e0e\u8d85\u65f6\u91ca\u653e5.5 \u6dfb\u52a0\u4e0e\u5237\u65b05.6 \u65b0\u94fe\u63a5\u63a5\u51655.7 \u7ebf\u7a0b\u8fb9\u754c6 \u5f00\u53d1\u4e2d\u9047\u5230\u7684\u95ee\u98987 \u5176\u4f59\u7ec6\u82828 \u603b\u7ed39 \u5e38\u89c1\u95ee\u9898","og_url":"https:\/\/www.wsisp.com\/helps\/118091.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-25T23:40:38+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261025234035-6ade9373463e0.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/118091.html","url":"https:\/\/www.wsisp.com\/helps\/118091.html","name":"\u4effmuduo\u5b9e\u73b0\u9ad8\u5e76\u53d1\u670d\u52a1\u5668\u2014\u2014EventLoop+_timer_wheel\u8282\u70b91 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-25T23:40:38+00:00","dateModified":"2026-10-25T23:40:38+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/118091.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/118091.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/118091.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4effmuduo\u5b9e\u73b0\u9ad8\u5e76\u53d1\u670d\u52a1\u5668\u2014\u2014EventLoop+_timer_wheel\u8282\u70b91"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/118091","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=118091"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/118091\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/118089"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=118091"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=118091"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=118091"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=118091"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}