ff576b2e07252446ab1ca73148b9cfb3c9b7e79ab4761069330b5e49f8f3105895ab661aa3f0c0409f4576f333abe79d853d2814115886eb97a0d5959f9c5a 874 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef BACKEND_H
  2. #define BACKEND_H
  3. #include "Event.hh"
  4. #include "Watcher.hh"
  5. #include "Signal.hh"
  6. #include <thread>
  7. class Backend {
  8. public:
  9. virtual ~Backend();
  10. void run();
  11. void notifyStarted();
  12. virtual void start();
  13. virtual void writeSnapshot(WatcherRef watcher, std::string *snapshotPath) = 0;
  14. virtual void getEventsSince(WatcherRef watcher, std::string *snapshotPath) = 0;
  15. virtual void subscribe(WatcherRef watcher) = 0;
  16. virtual void unsubscribe(WatcherRef watcher) = 0;
  17. static std::shared_ptr<Backend> getShared(std::string backend);
  18. void watch(WatcherRef watcher);
  19. void unwatch(WatcherRef watcher);
  20. void unref();
  21. void handleWatcherError(WatcherError &err);
  22. std::mutex mMutex;
  23. std::thread mThread;
  24. private:
  25. std::unordered_set<WatcherRef> mSubscriptions;
  26. Signal mStartedSignal;
  27. void handleError(std::exception &err);
  28. };
  29. #endif