From a369c484113b240f042c62cba80afd26df91e4ca Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 24 Apr 2020 20:13:17 +0800 Subject: [PATCH] =?UTF-8?q?ioloop=E6=B7=BB=E5=8A=A0=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- a8/ioloop.cc | 11 +++++++++++ a8/ioloop.h | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/a8/ioloop.cc b/a8/ioloop.cc index 9853016..c068cb2 100644 --- a/a8/ioloop.cc +++ b/a8/ioloop.cc @@ -133,17 +133,21 @@ namespace a8 a8::EpollEventHandler* handler = (a8::EpollEventHandler*)events[i].data.ptr; if (events[i].events & EPOLLOUT) { handler->DoSend(); + ++send_times; } if (events[i].events & EPOLLIN) { handler->DoRecv(); + ++recv_times; } if (events[i].events & EPOLLRDHUP || events[i].events & EPOLLHUP || events[i].events & EPOLLERR ) { handler->DoError(); + ++error_times; } } + ++run_times; } ProcessIMMsg(context); delete [] events; @@ -176,25 +180,30 @@ namespace a8 case kFreeClient: { _IMFreeClient(context, param); + ++free_times; } break; case kShutdown: { _IMShutdown(context, param); + ++shutdown_times; } break; case kAsyncConnect: { _IMAsyncConnect(context, param); + ++connect_times; } break; case kAsyncClose: { _IMAsyncClose(context, param); + ++close_times; } break; } } + ++immsg_times; } } @@ -203,12 +212,14 @@ namespace a8 #ifdef DEBUG a8::UdpLog::Instance()->Info("OnEvent %d", {data}); #endif + ++event_times; } void IoLoop::OnTimer(void* context, unsigned long long data) { IoLoopThreadContext* thread_context = (IoLoopThreadContext*)context; ++thread_context->tick; + ++timer_times; #ifdef DEBUG a8::UdpLog::Instance()->Info("OnTimer %d", {data}); #endif diff --git a/a8/ioloop.h b/a8/ioloop.h index 34224a4..fc89b29 100644 --- a/a8/ioloop.h +++ b/a8/ioloop.h @@ -15,6 +15,19 @@ namespace a8 IoLoop() {}; friend class a8::Singleton; + public: + std::atomic run_times = {0}; + std::atomic timer_times = {0}; + std::atomic event_times = {0}; + std::atomic free_times = {0}; + std::atomic shutdown_times = {0}; + std::atomic connect_times = {0}; + std::atomic close_times = {0}; + std::atomic send_times = {0}; + std::atomic recv_times = {0}; + std::atomic error_times = {0}; + std::atomic immsg_times = {0}; + public: void Init(int thread_num); void UnInit();