From 27911e4c08bd97570e528b2f35fe8fb73503c35b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 18 Dec 2022 21:33:15 +0100 Subject: Storage: add Head::reload method --- include/erebos/storage.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/erebos/storage.h b/include/erebos/storage.h index 62619a2..01aeada 100644 --- a/include/erebos/storage.h +++ b/include/erebos/storage.h @@ -547,6 +547,7 @@ public: const Stored & stored() const { return mstored; } const Ref & ref() const { return mstored.ref(); } + optional> reload() const; std::optional> update(const std::function(const Stored &)> &) const; WatchedHead watch(const std::function &)> &) const; @@ -631,6 +632,12 @@ Head Storage::storeHead(const Stored & val) const return Head(id, val); } +template +optional> Head::reload() const +{ + return ref().storage().template head(id()); +} + template std::optional> Head::update(const std::function(const Stored &)> & f) const { @@ -657,7 +664,7 @@ WatchedHead Head::watch(const std::function &)> & watch template Bhv Head::behavior() const { - auto cur = ref().storage().template head(id()); + auto cur = reload(); return make_shared>(cur ? *cur : *this); } -- cgit v1.2.3