mirror of https://github.com/trapexit/mergerfs.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
969 B
59 lines
969 B
#pragma once
|
|
|
|
#include "boost/unordered/concurrent_flat_map.hpp"
|
|
|
|
#include "fileinfo.hpp"
|
|
|
|
#include <functional>
|
|
#include <map>
|
|
#include <string>
|
|
|
|
|
|
constexpr int INVALID_BACKING_ID = -1;
|
|
|
|
class State
|
|
{
|
|
public:
|
|
State();
|
|
|
|
public:
|
|
struct OpenFile
|
|
{
|
|
OpenFile()
|
|
: ref_count(0),
|
|
backing_id(INVALID_BACKING_ID),
|
|
fi(nullptr)
|
|
{
|
|
}
|
|
|
|
int ref_count;
|
|
int backing_id;
|
|
FileInfo *fi;
|
|
};
|
|
|
|
public:
|
|
struct GetSet
|
|
{
|
|
std::function<std::string()> get;
|
|
std::function<int(const std::string_view)> set;
|
|
};
|
|
|
|
void set_getset(const std::string &name,
|
|
const State::GetSet &gs);
|
|
|
|
int get(const std::string &key,
|
|
std::string &val);
|
|
int set(const std::string &key,
|
|
const std::string_view val);
|
|
|
|
public:
|
|
using OpenFileMap = boost::concurrent_flat_map<u64,OpenFile>;
|
|
|
|
private:
|
|
std::map<std::string,GetSet> _getset;
|
|
|
|
public:
|
|
OpenFileMap open_files;
|
|
};
|
|
|
|
extern State state;
|