CatapultServer  v0.5.0.1 (Elephant)
AtomicIncrementDecrementGuard.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include <atomic>
23 
24 namespace catapult { namespace utils {
25 
27  template<typename T>
29  public:
30  explicit AtomicIncrementDecrementGuard(std::atomic<T>& value) : m_value(value) {
31  ++m_value;
32  }
33 
35  --m_value;
36  }
37 
38  private:
39  std::atomic<T>& m_value;
40 
41  public:
44  };
45 
47  template<typename T>
50  }
51 }}
catapult::utils::AtomicIncrementDecrementGuard::~AtomicIncrementDecrementGuard
~AtomicIncrementDecrementGuard()
Definition: AtomicIncrementDecrementGuard.h:34
catapult::utils::AtomicIncrementDecrementGuard::AtomicIncrementDecrementGuard
AtomicIncrementDecrementGuard(std::atomic< T > &value)
Definition: AtomicIncrementDecrementGuard.h:30
catapult::utils::MakeIncrementDecrementGuard
AtomicIncrementDecrementGuard< T > MakeIncrementDecrementGuard(std::atomic< T > &value)
Factory function for creating AtomicIncrementDecrementGuard<T>.
Definition: AtomicIncrementDecrementGuard.h:48
catapult::utils::AtomicIncrementDecrementGuard::operator=
AtomicIncrementDecrementGuard< T > & operator=(const AtomicIncrementDecrementGuard< T > &rhs)=default
catapult::utils::AtomicIncrementDecrementGuard
RAII class that increments an atomic on construction and decrements it on destruction.
Definition: AtomicIncrementDecrementGuard.h:28
catapult::utils::AtomicIncrementDecrementGuard::m_value
std::atomic< T > & m_value
Definition: AtomicIncrementDecrementGuard.h:39
catapult
Definition: AddressExtractionExtension.cpp:28