Note that the order of initialization in the member list is not list order but:
- The order of declarations in the class!
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;
}
}
The initialization order is given by
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;
decided here. . .
Be careful when there are sequential dependencies in the member initialization list!