注意在成员列表中初始化的顺序并不是列表顺序 而是:

  • 在类中声明的顺序!
EventLoop::EventLoop() :looping(false), quit(false),_tid(curThreadId()), poller(new Poller(this)){//, timerQueue(new TimerQueue(this)) {
	std::cout<<_tid<<std::endl;
	if (t_LoopInThisThread) {
//		LOG_FATAL << "Another EventLoop " << t_LoopInThisThread << " Exists in this Thread " << _tid;
	}
	else {
		t_LoopInThisThread = this;
	}
}


初始化顺序是由

private:
		typedef std::vector<Channel*> ChannelVec;
		std::unique_ptr<Poller> poller;
		std::unique_ptr<TimerQueue> timerQueue;
		Timestamp pollReturnTime;
		ChannelVec activeChannels; 
		ThreadId _tid;
		bool looping;
		bool quit;

这里决定的。。。

在成员初始化列表中有前后顺序依赖的时候一定要注意!

相关文章:

  • 2021-10-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-11
  • 2022-12-23
  • 2021-07-20
猜你喜欢
  • 2022-12-23
  • 2021-08-02
  • 2022-12-23
  • 2021-05-27
相关资源
相似解决方案