Debian Codegraph @

node/@parcel/watcher/src/Backend.hh

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