From 2abd6593c8b047d3fd579aa6cc0058bbebe266f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 17 Jan 2021 21:59:46 +0100 Subject: Server watching local state head --- include/erebos/storage.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/erebos/storage.h') diff --git a/include/erebos/storage.h b/include/erebos/storage.h index 34ed9df..29eaa8f 100644 --- a/include/erebos/storage.h +++ b/include/erebos/storage.h @@ -107,6 +107,7 @@ protected: static UUID storeHead(UUID type, const Ref & ref); static bool replaceHead(UUID type, UUID id, const Ref & old, const Ref & ref); static std::optional updateHead(UUID type, UUID id, const Ref & old, const std::function &); + void watchHead(UUID type, UUID id, const std::function) const; }; class Digest @@ -482,6 +483,7 @@ public: const Ref & ref() const { return mstored.ref(); } std::optional> update(const std::function(const Stored &)> &) const; + void watch(const std::function &)> &) const; private: UUID mid; @@ -536,6 +538,14 @@ std::optional> Head::update(const std::function(const Store return Head(mid, *res); } +template +void Head::watch(const std::function &)> & watcher) const +{ + stored().ref().storage().watchHead(T::headTypeId, id(), [id = id(), watcher] (const Ref & ref) { + watcher(Head(id, ref)); + }); +} + } namespace std -- cgit v1.2.3