If I have understood correctly destroying object is currently not thread safe.
Let's look at example(modified, from https://github.com/Kistler-Group/sdbus-cpp/blob/master/docs/using-sdbus-c++.md):
class Concatenator : public sdbus::AdaptorInterfaces<org::sdbuscpp::Concatenator_adaptor /*, more adaptor classes if there are more interfaces*/>
{
public:
Concatenator(sdbus::IConnection& connection, std::string objectPath)
: AdaptorInterfaces(connection, std::move(objectPath))
{
registerAdaptor();
}
~Concatenator()
{
unregisterAdaptor();
}
const std::string member_ = "12313123213";
protected:
std::string concatenate(const std::vector<int32_t>& numbers, const std::string& separator) override
{
std::this_thread::sleep_for(300s);
return member_;
}
};
In this case calling unregisterAdaptor will stop new calls to concatenate method from happening, but if some call is already waiting on std::this_thread::sleep_for(300s); then when wait finishes it will access member_, which was already destroyed.
Is my reasoning correct?
If I have understood correctly destroying object is currently not thread safe.
Let's look at example(modified, from https://github.com/Kistler-Group/sdbus-cpp/blob/master/docs/using-sdbus-c++.md):
In this case calling unregisterAdaptor will stop new calls to concatenate method from happening, but if some call is already waiting on std::this_thread::sleep_for(300s); then when wait finishes it will access member_, which was already destroyed.
Is my reasoning correct?