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