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