From 5d30941aabe130f3e1ebfcd535ac5695f91baee0 Mon Sep 17 00:00:00 2001 From: Hayodea Hakol Date: Tue, 16 Sep 2025 18:20:08 -0400 Subject: [PATCH] AsyncLoop: Add copy constr + assignment op Make nTotal non-const. --- include/asynchronousLoop.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/include/asynchronousLoop.h b/include/asynchronousLoop.h index 412fbcb..2f5a685 100644 --- a/include/asynchronousLoop.h +++ b/include/asynchronousLoop.h @@ -14,6 +14,22 @@ public: : nTotal(nTotal), nSucceeded(nSucceeded), nFailed(nFailed) {} + AsynchronousLoop(const AsynchronousLoop& other) + : nTotal(other.nTotal), + nSucceeded(other.nSucceeded.load()), nFailed(other.nFailed.load()) + {} + + AsynchronousLoop& operator=(const AsynchronousLoop& other) + { + if (this != &other) + { + nTotal = other.nTotal; + nSucceeded.store(other.nSucceeded.load()); + nFailed.store(other.nFailed.load()); + } + return *this; + } + bool isComplete(void) const { return nSucceeded + nFailed == nTotal; @@ -39,7 +55,7 @@ public: } public: - const unsigned int nTotal; + unsigned int nTotal; std::atomic nSucceeded, nFailed; };