1
1
mirror of http://git.sesse.net/plocate synced 2025-10-05 23:42:49 +02:00
Files
plocate/access_rx_cache.h
Steinar H. Gunderson d0f2469aed Fix an issue where the database could be built with the wrong check_visibility flag.
The check_visibility flag would never be set in the header, and thus be set to some
random variable instead of what the user wanted.
2020-12-05 10:50:49 +01:00

32 lines
744 B
C++

#ifndef _ACCESS_RX_CACHE_H
#define _ACCESS_RX_CACHE_H 1
#include <functional>
#include <map>
#include <mutex>
#include <string>
#include <unordered_map>
#include <vector>
class IOUringEngine;
class AccessRXCache {
public:
AccessRXCache(IOUringEngine *engine, bool check_visibility)
: engine(engine), check_visibility(check_visibility) {}
void check_access(const char *filename, bool allow_async, std::function<void(bool)> cb);
private:
std::unordered_map<std::string, bool> cache;
struct PendingStat {
std::string filename;
std::function<void(bool)> cb;
};
std::map<std::string, std::vector<PendingStat>> pending_stats;
IOUringEngine *engine;
std::mutex mu;
bool check_visibility;
};
#endif // !defined(_ACCESS_RX_CACHE_H)