Don't auto-throw non-viral callee exceptions before callerLambda

This commit is contained in:
2026-06-06 04:47:59 -04:00
parent 8a7d4272bd
commit edde8f4a64
3 changed files with 47 additions and 12 deletions
+40
View File
@@ -0,0 +1,40 @@
#ifndef NON_VIRAL_COMPLETION_H
#define NON_VIRAL_COMPLETION_H
#include <exception>
#include <utility>
namespace sscl::co {
class NonViralCompletion
{
public:
explicit NonViralCompletion(std::exception_ptr &exceptionPtr)
: exceptionPtr(exceptionPtr)
{}
bool hasException() const noexcept
{
return exceptionPtr != nullptr;
}
void checkAndRethrowException() const
{
if (exceptionPtr)
{
std::rethrow_exception(exceptionPtr);
}
}
std::exception_ptr releaseException() noexcept
{
return std::exchange(exceptionPtr, nullptr);
}
private:
std::exception_ptr &exceptionPtr;
};
} // namespace sscl::co
#endif // NON_VIRAL_COMPLETION_H