aboutsummaryrefslogtreecommitdiff
path: root/zencore/include
diff options
context:
space:
mode:
Diffstat (limited to 'zencore/include')
-rw-r--r--zencore/include/zencore/thread.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/zencore/include/zencore/thread.h b/zencore/include/zencore/thread.h
index 2aad22061..a9c96d422 100644
--- a/zencore/include/zencore/thread.h
+++ b/zencore/include/zencore/thread.h
@@ -163,6 +163,15 @@ public:
std::ptrdiff_t Remaining() const { return Counter.load(); }
+ // If you want to add dynamic count, make sure to set the initial counter to 1
+ // and then do a CountDown() just before wait to not trigger the event causing
+ // false positive completion results.
+ void AddCount(std::ptrdiff_t Count)
+ {
+ std::atomic_ptrdiff_t Old = Counter.fetch_add(Count);
+ ZEN_ASSERT_SLOW(Old > 0);
+ }
+
bool Wait(int TimeoutMs = -1)
{
std::ptrdiff_t Old = Counter.load();