FileManager v1.7.0
Manage access to files with async model
Loading...
Searching...
No Matches
Utility.cpp
1#include "Utility.h"
2
3#include "FileManager.h"
4
5using namespace std;
6
7namespace file_manager
8{
9 namespace utility
10 {
11 size_t pathHash::operator () (const filesystem::path& filePath) const noexcept
12 {
13 return hash<string>()(filePath.string());
14 }
15 }
16
17 namespace _utility
18 {
19 void addCache(filesystem::path&& filePath, string&& data)
20 {
21 Cache& cache = FileManager::getInstance().getCache();
22 unique_lock<mutex> lock(cache.cacheDataMutex);
23
24 if (cache.currentCacheSize + data.size() > cache.cacheSize)
25 {
26 return;
27 }
28
29 cache.cacheData.try_emplace(move(filePath), move(data));
30 }
31 }
32}
Cache & getCache()
Cache getter.
static FileManager & getInstance()
Singleton getter Also initialize thread pool with max threads for current hardware Default getter aft...