mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-20 23:16:27 -05:00
Change getattr and statx to bespoke policies
* Provides: slight improvement in performance as it no longer will need to find and then act on the files. * It doesn't make sense to support all original policy types. Most people used 'newest' or 'ff' and 'combine' is a better default which has same runtime as 'newest' but with better output.
This commit is contained in:
parent
965e26989c
commit
b3b8e793f9
145 changed files with 3803 additions and 1192 deletions
55
src/func_wrapper.hpp
Normal file
55
src/func_wrapper.hpp
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#pragma once
|
||||
|
||||
#include "atomicsharedptr.hpp"
|
||||
#include "tofrom_string.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
template<typename BaseType,
|
||||
typename FactoryType,
|
||||
typename ReturnType,
|
||||
typename... Args>
|
||||
class FuncWrapper : public ToFromString
|
||||
{
|
||||
private:
|
||||
AtomicSharedPtr<BaseType> _impl;
|
||||
|
||||
public:
|
||||
explicit FuncWrapper(const std::string &name_)
|
||||
{
|
||||
_impl.store(FactoryType::make(name_));
|
||||
assert(not _impl.is_null());
|
||||
}
|
||||
|
||||
public:
|
||||
ReturnType
|
||||
operator()(Args&&... args)
|
||||
{
|
||||
return _impl(std::forward<Args>(args)...);
|
||||
//return _impl(args...);
|
||||
}
|
||||
|
||||
public:
|
||||
std::string
|
||||
to_string() const
|
||||
{
|
||||
return std::string{_impl.load()->name()};
|
||||
}
|
||||
|
||||
int
|
||||
from_string(const std::string_view str_)
|
||||
{
|
||||
std::shared_ptr<BaseType> p;
|
||||
|
||||
p = FactoryType::make(str_);
|
||||
if(!p)
|
||||
return -EINVAL;
|
||||
|
||||
_impl.store(p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue