Lines Matching refs:ctx
47 auto ctx = std::make_shared<EventContext>(); in AddFileDescriptor() local
48 CHECK_NOTNULL(ctx, false, "create EventContext FAILED!"); in AddFileDescriptor()
49 ctx->fd = fd; in AddFileDescriptor()
50 ctx->onReadable = onReadable; in AddFileDescriptor()
51 ctx->onWritable = onWritable; in AddFileDescriptor()
54 CHECK_TRUE(AddContextLocked(ctx), false, "add context for %d failed!", fd); in AddFileDescriptor()
64 auto ctx = it->second; in RemoveFileDescriptor() local
65 CHECK_NOTNULL(ctx, false, "ctx null!"); in RemoveFileDescriptor()
66 CHECK_TRUE(RemoveContextLocked(ctx), false, "remove context for %d failed!", fd); in RemoveFileDescriptor()
70 bool EpollEventPoller::AddContextLocked(const EventContextPtr& ctx) in AddContextLocked() argument
72 context_[ctx->fd] = ctx; in AddContextLocked()
73 return UpdateEvent(EPOLL_CTL_ADD, ctx); in AddContextLocked()
76 bool EpollEventPoller::RemoveContextLocked(const EventContextPtr& ctx) in RemoveContextLocked() argument
78 context_.erase(ctx->fd); in RemoveContextLocked()
79 CHECK_TRUE(UpdateEvent(EPOLL_CTL_DEL, ctx), false, "update fd %d ctx FAILED!", ctx->fd); in RemoveContextLocked()
97 bool EpollEventPoller::UpdateEvent(int op, const EventContextPtr& ctx) in UpdateEvent() argument
100 if (ctx->onReadable) { in UpdateEvent()
103 if (ctx->onWritable) { in UpdateEvent()
106 event.data.ptr = ctx.get(); in UpdateEvent()
109 HILOG_DEBUG(LOG_CORE, "poll set %s %d %x start!", name.c_str(), ctx->fd, event.events); in UpdateEvent()
110 int retval = epoll_ctl(epollFd_, op, ctx->fd, &event); in UpdateEvent()
112 HILOG_DEBUG(LOG_CORE, "poll set %s %d %x done!", name.c_str(), ctx->fd, event.events); in UpdateEvent()
132 auto ctx = reinterpret_cast<EventContext*>(eventVec[i].data.ptr); in Run() local
133 if (ctx != nullptr) { in Run()
134 HandleEvent(eventVec[i].events, *ctx); in Run()
140 void EpollEventPoller::HandleEvent(uint32_t events, const EventContext& ctx) in HandleEvent() argument
143 if (ctx.onReadable) { in HandleEvent()
144 ctx.onReadable(); in HandleEvent()
147 if (ctx.onWritable) { in HandleEvent()
148 ctx.onWritable(); in HandleEvent()