identt
SharedCounter.hpp
Go to the documentation of this file.
1 
33 #ifndef _IDENTT_UTILS_SHARED_COUNTER_HPP_
34 #define _IDENTT_UTILS_SHARED_COUNTER_HPP_
35 
36 #include <utils/SharedObject.hpp>
37 
38 namespace identt {
39 namespace utils {
40 class SharedCounter : public SharedObject<uint64_t> {
41 public:
42  using LockT = SharedObject<uint64_t>::LockT;
43  using WriteLockT = SharedObject<uint64_t>::WriteLockT;
44  using ReadLockT = SharedObject<uint64_t>::ReadLockT;
45 
50  SharedCounter(const SharedCounter&) = delete;
51  SharedCounter& operator=(const SharedCounter&) = delete;
52 
57  SharedCounter() : SharedObject<uint64_t>(0) {}
58 
62  virtual ~SharedCounter () {}
63 
70  uint64_t GetNext()
71  {
72  WriteLockT writelock(mutex_);
73  ++t_;
74  return t_;
75  }
76 
77 };
78 } // namespace utils
79 } // namespace identt
80 #endif /* _IDENTT_UTILS_SHARED_COUNTER_HPP_ */
virtual ~SharedCounter()
destructor
Definition: SharedCounter.hpp:62
Definition: SharedCounter.hpp:40
Definition: SharedObject.hpp:43
SharedCounter()
Constructor : default.
Definition: SharedCounter.hpp:57
Definition: CryptoBase.hpp:49
uint64_t GetNext()
GetNext : increment and get next value.
Definition: SharedCounter.hpp:70