mirror of
https://github.com/latentPrion/libspinscale.git
synced 2026-08-12 23:48:22 +00:00
Summarize and merge MultiOperationResultSetWithException from settled Groups.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,6 +4,9 @@
|
||||
#include <exception>
|
||||
|
||||
namespace sscl {
|
||||
namespace co {
|
||||
struct Group;
|
||||
} // namespace co
|
||||
|
||||
/** Plain aggregate for fan-out / fan-in results returned from coroutines. */
|
||||
struct MultiOperationResultSet
|
||||
@@ -38,9 +41,29 @@ struct MultiOperationResultSetWithException
|
||||
memberFailureException(memberFailureExceptionIn)
|
||||
{}
|
||||
|
||||
/** Summarize a settled Group into counts + aggregated member failure. */
|
||||
explicit MultiOperationResultSetWithException(const co::Group &group);
|
||||
|
||||
bool hasMemberFailure() const
|
||||
{ return memberFailureException != nullptr; }
|
||||
|
||||
/** Combine this result set with another phase's counts and exception. */
|
||||
MultiOperationResultSetWithException mergeWith(
|
||||
const MultiOperationResultSetWithException &other) const
|
||||
{
|
||||
std::exception_ptr memberFailure = memberFailureException;
|
||||
if (!memberFailure && other.hasMemberFailure()) {
|
||||
memberFailure = other.memberFailureException;
|
||||
}
|
||||
|
||||
return MultiOperationResultSetWithException(
|
||||
MultiOperationResultSet(
|
||||
results.nTotal + other.results.nTotal,
|
||||
results.nSucceeded + other.results.nSucceeded,
|
||||
results.nFailed + other.results.nFailed),
|
||||
memberFailure);
|
||||
}
|
||||
|
||||
MultiOperationResultSet results;
|
||||
std::exception_ptr memberFailureException = nullptr;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user