mirror of
https://github.com/latentPrion/libspinscale.git
synced 2026-06-24 11:58:33 +00:00
Don't auto-throw non-viral callee exceptions before callerLambda
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user