]> git.sesse.net Git - plocate/blob - access_rx_cache.h
Release plocate 1.1.22.
[plocate] / access_rx_cache.h
1 #ifndef _ACCESS_RX_CACHE_H
2 #define _ACCESS_RX_CACHE_H 1
3
4 #include <functional>
5 #include <map>
6 #include <mutex>
7 #include <string>
8 #include <unordered_map>
9 #include <vector>
10
11 class IOUringEngine;
12
13 class AccessRXCache {
14 public:
15         AccessRXCache(IOUringEngine *engine, bool check_visibility)
16                 : engine(engine), check_visibility(check_visibility) {}
17         void check_access(const char *filename, bool allow_async, std::function<void(bool)> cb);
18
19 private:
20         std::unordered_map<std::string, bool> cache;
21         struct PendingStat {
22                 std::string filename;
23                 std::function<void(bool)> cb;
24         };
25         std::map<std::string, std::vector<PendingStat>> pending_stats;
26         IOUringEngine *engine;
27         std::mutex mu;
28         bool check_visibility;
29 };
30
31 #endif  // !defined(_ACCESS_RX_CACHE_H)