WebServer icon indicating copy to clipboard operation
WebServer copied to clipboard

runinloop问题

Open miku-fan opened this issue 3 years ago • 1 comments

HttpData.cpp 的 handleConn() 函数中:

loop_->runInLoop(bind(&HttpData::handleClose, shared_from_this()));

这里用 runinloop 真的有必要吗,因为这里loop_ 就是 HttpData 内指向本 eventloop 的指针,可以确定是在本线程(eventloop)执行的吧。所以跟直接调用 handleClose() 有什么区别?

miku-fan avatar Aug 09 '22 13:08 miku-fan

可以直接调的,用runInLoop的原因只是因为这样不用动脑,并且一定不会错,follow自己的风格就好了

linyacool avatar Aug 28 '22 16:08 linyacool