Some checks failed
continuous-integration/drone/push Build is failing
The trick being caching lol.
38 lines
601 B
C++
38 lines
601 B
C++
#pragma once
|
|
#include "lib/KMutex.h"
|
|
#include <luna/Buffer.h>
|
|
#include <luna/HashMap.h>
|
|
#include <luna/LinkedList.h>
|
|
|
|
class StorageCache : public LinkedListNode<StorageCache>
|
|
{
|
|
public:
|
|
struct CacheEntry
|
|
{
|
|
Buffer buffer {};
|
|
};
|
|
|
|
void lock()
|
|
{
|
|
return m_mutex.lock();
|
|
}
|
|
|
|
void unlock()
|
|
{
|
|
return m_mutex.unlock();
|
|
}
|
|
|
|
Result<CacheEntry*> fetch_entry(u64 block);
|
|
|
|
void clear();
|
|
|
|
static void clear_caches();
|
|
|
|
StorageCache();
|
|
~StorageCache();
|
|
|
|
private:
|
|
HashMap<u64, CacheEntry> m_cache_entries;
|
|
KMutex<100> m_mutex;
|
|
};
|