chenshuo / muduo

Event-driven network library for multi-threaded Linux server in C++11
https://github.com/chenshuo/muduo
Other
14.85k stars 5.17k forks source link

Solve the problem that the bound object has been destroyed during callback for TcpClient #489

Open x724172556 opened 4 years ago

x724172556 commented 4 years ago

之前回复过大神,我现在有一些想法,关于TcpClient销毁,但是回调仍然依赖于这个对象或者子对象,我这里在回调部分,全都使用了智能指针,并且将Connector的构造函数隐藏,只能使用Connector::create来创造智能指针对象,避免使用者,在使用过程中,在栈中构造Connector,在我的工程代码环境中测试过,没有出现之前提到的由于对象销毁,回调时依赖于无效的指针的问题,大神可以看看,这样改行不行