kla*_*aus 1 boost deadlock pthreads boost-asio
我使用封装了boost::asio::io_service的 c++ 类。
class IoService {
public:
static IoService& getInstance() {
static IoService instance;
return instance;
}
void start() {
_ioServiceThread = std::thread(&IoService::run, this);
}
void stop() {
_ioService.stop();
_ioServiceThread.join();
}
void run() {
_ioService.run();
}
private:
IoService();
~IoService();
IoService(const IoService& old) = delete;
IoService(const IoService&& old) = delete;
IoService& operator=(const IoService& old) = delete;
IoService& operator=(const IoService&& old) = delete;
boost::asio::io_service _ioService;
std::thread _ioServiceThread;
};
Run Code Online (Sandbox Code Playgroud)
但是当我调用 stop 方法时,程序在连接时崩溃:
terminate called after throwing an instance of 'std::system_error'
what(): Resource deadlock avoided
Aborted
Run Code Online (Sandbox Code Playgroud)
你怎么认为 ?
| 归档时间: |
|
| 查看次数: |
3680 次 |
| 最近记录: |