};
DebugPortImpl::~DebugPortImpl() {
+ _I("");
Dispose();
}
return 0;
}
-DebugPortImpl impl;
+DebugPortImpl* impl = new DebugPortImpl();
+
+__attribute__((destructor)) static void destructor() {
+ delete impl;
+ impl = nullptr;
+}
+
} // namespace
bool DebugPort::IsConnected() {
- impl.Init();
- return impl.IsConnected();
+ if (impl == nullptr)
+ return false;
+
+ impl->Init();
+ return impl->IsConnected();
}
void DebugPort::AddSession(std::string port_name,
std::shared_ptr<Port> main_port,
std::shared_ptr<Port> delegate_port) {
- impl.Init();
- return impl.AddSession(std::move(port_name), std::move(main_port),
+ if (impl == nullptr)
+ return;
+
+ impl->Init();
+ return impl->AddSession(std::move(port_name), std::move(main_port),
std::move(delegate_port));
}
void DebugPort::RemoveSession(int port) {
- impl.Init();
- impl.RemoveSession(port);
+ if (impl == nullptr)
+ return;
+
+ impl->Init();
+ impl->RemoveSession(port);
}
void DebugPort::Send(int port, bool is_read, uint32_t seq, const void* buf,
unsigned int size) {
- impl.Init();
- impl.Send(port, is_read, seq, buf, size);
+ if (impl == nullptr)
+ return;
+
+ impl->Init();
+ impl->Send(port, is_read, seq, buf, size);
}
} // namespace internal