Index: src/libchcore/TEventCounter.h =================================================================== diff -u -N -r5127141ac49a45db27f748dfb659d31f2e4983c4 -rd99302fce795dbb5139659016a5da7948f141fb4 --- src/libchcore/TEventCounter.h (.../TEventCounter.h) (revision 5127141ac49a45db27f748dfb659d31f2e4983c4) +++ src/libchcore/TEventCounter.h (.../TEventCounter.h) (revision d99302fce795dbb5139659016a5da7948f141fb4) @@ -35,7 +35,7 @@ public: explicit TEventCounter(T initialValue = 0) : m_event(true, false), - m_tCounter(initialValue), + m_spCounter(std::make_shared>(initialValue)), m_tMaxUsed(initialValue) { UpdateEvent(); @@ -46,23 +46,18 @@ void Increase() { - ++m_tCounter; - if(m_tCounter > m_tMaxUsed) - m_tMaxUsed = m_tCounter; + m_spCounter->Increase(); + if(m_spCounter->GetValue() > m_tMaxUsed) + m_tMaxUsed = m_spCounter->GetValue(); UpdateEvent(); } void Decrease() { - --m_tCounter; + m_spCounter->Decrease(); UpdateEvent(); } - T GetCounter() const - { - return m_tCounter; - } - T GetMaxUsed() const { return m_tMaxUsed; @@ -73,16 +68,21 @@ return m_event.Handle(); } + TSharedCountPtr GetSharedCount() + { + return m_spCounter; + } + private: void UpdateEvent() { - bool bIsEqual = (m_tCounter == CompareValue); + bool bIsEqual = (m_spCounter->GetValue() == CompareValue); m_event.SetEvent(EventMode == EEventCounterMode::eSetIfEqual ? bIsEqual : !bIsEqual); } private: TEvent m_event; - T m_tCounter; + TSharedCountPtr m_spCounter; T m_tMaxUsed; }; }