1 #pragma once 2 3 #include <systypes/base.h> 4 5 #include <list> 6 #include <mutex> 7 8 #include "memory_utils.h" 9 #include "region.h" 10 11 12 13 /* A memory pool abstraction. */ 14 15 class Memory 16 { 17 protected: 18 std::mutex _lock; 19 20 unsigned int _limit; 21 offset_t _region_size; 22 bool _limited; 23 24 Region *allocate(offset_t size); 25 26 public: 27 explicit Memory(unsigned int limit, offset_t region_size=PAGE_SIZE); 28 29 explicit Memory(); 30 31 offset_t region_size() 32 { return _region_size; } 33 34 Region *region(offset_t size); 35 36 Region *region(); 37 38 void release(Region *region); 39 }; 40 41 // vim: tabstop=4 expandtab shiftwidth=4