A guard that protects resources of a given class from being detroyed if another thread still works with them.
More...
A guard that protects resources of a given class from being detroyed if another thread still works with them.
One might think this is not necessary, there is std::shared_ptr for it. But - for objects that don't have shared ownership which are out of control regarding construction/destruction (think of MeVisLab modules controlled by MeVisLab), you need to make sure that MeVisLab doesn't destroys your object while threads are working with it.
Synopsis:
{
private:
void foo()
{
auto handle = guard.handle();
std::thread([handle] {
auto lock = handle.lock();
if (lock) {
my_resource = "hallo";
}
else {
}
});
}
std::string my_resource;
};
A guard that protects resources of a given class from being detroyed if another thread still works wi...
Base class for an image processing module of the ML.
Definition at line 67 of file ResourceDestructionGuard.h.