From be323e65108f4c1d57312a4d26a6a24d3a380c75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 28 May 2023 20:48:07 +0200 Subject: Storage: wait for scheduled watch callbacks --- include/erebos/storage.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include') 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 mstored; }; +/** + * Manages registered watch callbacks to Head object using RAII principle. + */ template class WatchedHead : public Head { @@ -590,6 +593,18 @@ public: static_cast &>(*this) = h; return *this; } + + /// Destructor stops the watching started with Head::watch call. + /** + * Once the WatchedHead object is destroyed, no further Head 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(); }; -- cgit v1.2.3