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 --- src/storage.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/storage.h') diff --git a/src/storage.h b/src/storage.h index 30e4213..c6b5ed2 100644 --- a/src/storage.h +++ b/src/storage.h @@ -45,6 +45,24 @@ public: virtual void storeKey(const Digest &, const vector &) = 0; }; +class StorageWatchCallback +{ +public: + StorageWatchCallback(int id, const function callback): + id(id), callback(callback) {} + + void schedule(UUID, const Digest &); + void run(); + + const int id; + +private: + const function callback; + + std::recursive_mutex runMutex; + optional> scheduled; +}; + class FilesystemStorage : public StorageBackend { public: @@ -85,7 +103,7 @@ private: int inotify = -1; int inotifyWakeup = -1; int nextWatcherId = 1; - unordered_multimap>> watchers; + unordered_multimap> watchers; unordered_map watchMap; }; @@ -117,7 +135,7 @@ private: mutex watcherLock; int nextWatcherId = 1; - unordered_multimap>> watchers; + unordered_multimap> watchers; }; class ChainStorage : public StorageBackend -- cgit v1.2.3