Classes for streams, contexts, events etc. all make CUDA API calls on destruction - and those calls can, in theory, fail. Not just due to bugs in the wrappers, but due to driver issues, hardware issues, or even the developer using the wrapper artificially destroying things before the wrapper dtor kicks into action (and that's not even difficult to do: You can always get the wrapped handle).
Given that fact... what should I do with failure within the destructors? Should I still throw an exception, risking std::terminate in case the stack is being unwound? Or - should I fail silently, and "swallow" the error?
A third alternative would be checking std::uncaught_exception() and deciding based on that; but that means complex and somewhat convoluted destructor behavior.
Classes for streams, contexts, events etc. all make CUDA API calls on destruction - and those calls can, in theory, fail. Not just due to bugs in the wrappers, but due to driver issues, hardware issues, or even the developer using the wrapper artificially destroying things before the wrapper dtor kicks into action (and that's not even difficult to do: You can always get the wrapped handle).
Given that fact... what should I do with failure within the destructors? Should I still throw an exception, risking std::terminate in case the stack is being unwound? Or - should I fail silently, and "swallow" the error?
A third alternative would be checking
std::uncaught_exception()
and deciding based on that; but that means complex and somewhat convoluted destructor behavior.