I have designed template classes OwnedObjectVector and OwnedObjectSet, which I am using to maintain ownership of allocated objects. I've done this so that in the case of an exception being thrown, and the destructor being called on OwnedObjectVector, the allocated objects can be freed safely.
Since I am using an ordinary std::vector and std::set in the implementation, I have wrapped my accesses with a mutex. The question which arises however, is whether or not a destructor should use a mutex to access the internal data structures. This is something I need advice on... does it make sense that a destructor should use a mutex?
What if the destructor is called, while other functions are waiting for the mutex? Is that even possible? Is it possible somehow that there is a mutexed call right after the call to the destructor?
What will generally happen with exceptions in TBB code? For example, suppose that a class has multiple executing functions, and one of them throws an exception. What will happen to the other function calls? This is a larger question, which I suspect has already been answered on the forum. I'll search around for an answer to this one.