2021-03-20 | Paul Boddie | raw annotate files changeset graph | Changed the preallocated memory pool to obtain all its memory at once. Moved the allocate method from the base class to the incremental memory pool, eliminating the separate base class implementation file. |
1 #pragma once 2 3 #include <systypes/base.h> 4 5 #include <mutex> 6 7 #include "memory_utils.h" 8 #include "region.h" 9 10 11 12 /* A memory pool abstraction. */ 13 14 class Memory 15 { 16 protected: 17 std::mutex _lock; 18 offset_t _region_size; 19 20 public: 21 explicit Memory(offset_t region_size=PAGE_SIZE) 22 : _region_size(region_size) 23 { 24 } 25 26 virtual Region *region() = 0; 27 28 virtual void release(Region *region) = 0; 29 }; 30 31 // vim: tabstop=4 expandtab shiftwidth=4