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();