diff options
-rw-r--r-- | include/erebos/frp.h | 15 | ||||
-rw-r--r-- | src/frp.cpp | 5 |
2 files changed, 17 insertions, 3 deletions
diff --git a/include/erebos/frp.h b/include/erebos/frp.h index b60b29f..466da33 100644 --- a/include/erebos/frp.h +++ b/include/erebos/frp.h @@ -17,15 +17,24 @@ using std::monostate; using std::optional; using std::shared_ptr; using std::static_pointer_cast; -using std::tuple; using std::vector; using std::weak_ptr; +class BhvCurTime; + class BhvTime { BhvTime(uint64_t t): t(t) {} - friend class BhvCurTime; + friend BhvCurTime; public: + BhvTime(const BhvCurTime &); + + bool operator==(const BhvTime & other) const { return t == other.t; } + bool operator!=(const BhvTime & other) const { return t != other.t; } + bool operator<(const BhvTime & other) const { return t < other.t; } + bool operator<=(const BhvTime & other) const { return t <= other.t; } + bool operator>(const BhvTime & other) const { return t > other.t; } + bool operator>=(const BhvTime & other) const { return t >= other.t; } private: uint64_t t; @@ -42,6 +51,8 @@ public: BhvCurTime & operator=(const BhvCurTime &) = delete; BhvCurTime & operator=(BhvCurTime &&); + BhvTime time() const { return t.value(); } + private: optional<BhvTime> t; }; diff --git a/src/frp.cpp b/src/frp.cpp index 142fcd4..a16950c 100644 --- a/src/frp.cpp +++ b/src/frp.cpp @@ -10,13 +10,16 @@ using std::move; using std::mutex; using std::nullopt; using std::unique_lock; -using std::weak_ptr; mutex bhvTimeMutex; condition_variable bhvTimeCond; bool bhvTimeRunning = false; uint64_t bhvTimeLast = 0; +BhvTime::BhvTime(const BhvCurTime & ct): + BhvTime(ct.time()) +{} + BhvCurTime::BhvCurTime() { unique_lock lock(bhvTimeMutex); |