Example #1
0
void EventLoop::wakeupHandler(int fd, short events) {
  LOG(INFO) << "EventLoop::wakeupHandler() ok, I heard!!";
  uint64_t one = 1;
  ssize_t n = ::read(fd, &one, sizeof one);
  if (n != sizeof one) {
    LOG(ERROR) << "EventLoop::wakeupHandler() reads " << n <<" bytes instead of " << sizeof(one);
  }

  doPendingFunctors();
}
Example #2
0
void EventLoop::Loop() {
	assert(!m_bLooping);
	AssertInLoopThread();
	m_bLooping = true;
	m_bQuit = false;

	while (!m_bQuit) {
		m_ActiveChannels.clear();
		m_PollReturnTime = m_pPoller->Poll(POLL_TIME_MS, &m_ActiveChannels);
		for (ChannelList::const_iterator itor = m_ActiveChannels.begin(), end = m_ActiveChannels.end()
			; end != itor
			; ++ itor)
		{
			(*itor)->HandleEvent(m_PollReturnTime);
		}
		doPendingFunctors();
	}

//	LOG_TRACE << "EventLoop " << this << " stop looping";
	m_bLooping = false;
}