ioloop添加调试信息

This commit is contained in:
aozhiwei 2020-04-24 20:13:17 +08:00
parent 6770f48291
commit a369c48411
2 changed files with 24 additions and 0 deletions

View File

@ -133,17 +133,21 @@ namespace a8
a8::EpollEventHandler* handler = (a8::EpollEventHandler*)events[i].data.ptr; a8::EpollEventHandler* handler = (a8::EpollEventHandler*)events[i].data.ptr;
if (events[i].events & EPOLLOUT) { if (events[i].events & EPOLLOUT) {
handler->DoSend(); handler->DoSend();
++send_times;
} }
if (events[i].events & EPOLLIN) { if (events[i].events & EPOLLIN) {
handler->DoRecv(); handler->DoRecv();
++recv_times;
} }
if (events[i].events & EPOLLRDHUP || if (events[i].events & EPOLLRDHUP ||
events[i].events & EPOLLHUP || events[i].events & EPOLLHUP ||
events[i].events & EPOLLERR events[i].events & EPOLLERR
) { ) {
handler->DoError(); handler->DoError();
++error_times;
} }
} }
++run_times;
} }
ProcessIMMsg(context); ProcessIMMsg(context);
delete [] events; delete [] events;
@ -176,25 +180,30 @@ namespace a8
case kFreeClient: case kFreeClient:
{ {
_IMFreeClient(context, param); _IMFreeClient(context, param);
++free_times;
} }
break; break;
case kShutdown: case kShutdown:
{ {
_IMShutdown(context, param); _IMShutdown(context, param);
++shutdown_times;
} }
break; break;
case kAsyncConnect: case kAsyncConnect:
{ {
_IMAsyncConnect(context, param); _IMAsyncConnect(context, param);
++connect_times;
} }
break; break;
case kAsyncClose: case kAsyncClose:
{ {
_IMAsyncClose(context, param); _IMAsyncClose(context, param);
++close_times;
} }
break; break;
} }
} }
++immsg_times;
} }
} }
@ -203,12 +212,14 @@ namespace a8
#ifdef DEBUG #ifdef DEBUG
a8::UdpLog::Instance()->Info("OnEvent %d", {data}); a8::UdpLog::Instance()->Info("OnEvent %d", {data});
#endif #endif
++event_times;
} }
void IoLoop::OnTimer(void* context, unsigned long long data) void IoLoop::OnTimer(void* context, unsigned long long data)
{ {
IoLoopThreadContext* thread_context = (IoLoopThreadContext*)context; IoLoopThreadContext* thread_context = (IoLoopThreadContext*)context;
++thread_context->tick; ++thread_context->tick;
++timer_times;
#ifdef DEBUG #ifdef DEBUG
a8::UdpLog::Instance()->Info("OnTimer %d", {data}); a8::UdpLog::Instance()->Info("OnTimer %d", {data});
#endif #endif

View File

@ -15,6 +15,19 @@ namespace a8
IoLoop() {}; IoLoop() {};
friend class a8::Singleton<IoLoop>; friend class a8::Singleton<IoLoop>;
public:
std::atomic<long long> run_times = {0};
std::atomic<long long> timer_times = {0};
std::atomic<long long> event_times = {0};
std::atomic<long long> free_times = {0};
std::atomic<long long> shutdown_times = {0};
std::atomic<long long> connect_times = {0};
std::atomic<long long> close_times = {0};
std::atomic<long long> send_times = {0};
std::atomic<long long> recv_times = {0};
std::atomic<long long> error_times = {0};
std::atomic<long long> immsg_times = {0};
public: public:
void Init(int thread_num); void Init(int thread_num);
void UnInit(); void UnInit();