#ifndef MEMGRAPH_MEMORY_MEMORY_HPP #define MEMGRAPH_MEMORY_MEMORY_HPP #include #include #include "storage/model/record.hpp" #include "storage/model/vertex.hpp" #include "storage/model/edge.hpp" // TODO implement the memory engine using the allocator style allocation to // make this class non-dependent on the memory allocation strategy // TODO implement real recycling of vertices and edges to improve performance class MemoryEngine { public: template T* create(Args&&... args) { return new T(std::forward(args)...); } template T* allocate() { return static_cast(malloc(sizeof(T))); } template void recycle(Record* record) { recycle(&record->derived()); } void recycle(Vertex* v) { delete v; } void recycle(Edge* e) { delete e; } private: std::unique_lock acquire() { return std::unique_lock(lock); } SpinLock lock; }; #endif