Since commit e22553e ("eventfd: don't take the spinlock in eventfd_poll", 2015-02-17), eventfd is reading ctx->count outside ctx->wqh.lock. However, things aren't as simple as the read barrier in eventfd_poll would suggest. In fact, the read barrier, besides lacking a comment, is...
所以我们不设置EFD_SEMAPHOR,当PollLoop发现它被eventfd唤醒了,直接调用read(2)清零计数。 一切看起来都很和谐,下面我们来修改PollLoop让它能够被唤醒。2. 修改PollLoopclass PollLoop { private: PollEventHandlerPtr mWakeUpHandler; } 在reactor模式的echo服务器中,我们已经把监听某个文件描述符的时间封装到了事件...