summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2023-05-28 20:48:07 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2023-06-14 22:17:17 +0200
commitbe323e65108f4c1d57312a4d26a6a24d3a380c75 (patch)
tree2ddc81ef079f3d42fb4d4780a5fd1cf0d27ef7b5 /include
parent15ad6ae7bd64d8d7319d75dbbb0827addd22fef2 (diff)
Storage: wait for scheduled watch callbacks
Diffstat (limited to 'include')
-rw-r--r--include/erebos/storage.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/erebos/storage.h b/include/erebos/storage.h
index ed537eb..3a3073d 100644
--- a/include/erebos/storage.h
+++ b/include/erebos/storage.h
@@ -563,6 +563,9 @@ private:
Stored<T> mstored;
};
+/**
+ * Manages registered watch callbacks to Head<T> object using RAII principle.
+ */
template<class T>
class WatchedHead : public Head<T>
{
@@ -590,6 +593,18 @@ public:
static_cast<Head<T> &>(*this) = h;
return *this;
}
+
+ /// Destructor stops the watching started with Head<T>::watch call.
+ /**
+ * Once the WatchedHead object is destroyed, no further Head<T> changes
+ * will trigger the associated callback.
+ *
+ * The destructor also ensures that any scheduled callback run
+ * triggered by a previous change to the head is executed and finished
+ * before the destructor returns. The exception is when the destructor
+ * is called directly from the callback itself, in which case the
+ * destructor returns immediately.
+ */
~WatchedHead();
};