1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/memory_preallocated.h Sat Mar 20 01:41:43 2021 +0100
1.3 @@ -0,0 +1,27 @@
1.4 +#pragma once
1.5 +
1.6 +#include <list>
1.7 +#include <set>
1.8 +
1.9 +#include "memory.h"
1.10 +
1.11 +
1.12 +
1.13 +/* A memory pool preallocating its memory. */
1.14 +
1.15 +class MemoryPreallocated : public Memory
1.16 +{
1.17 +protected:
1.18 + unsigned int _limit;
1.19 + std::list<Region *> _free;
1.20 + std::set<Region *> _used;
1.21 +
1.22 +public:
1.23 + explicit MemoryPreallocated(unsigned int limit, offset_t region_size=PAGE_SIZE);
1.24 +
1.25 + virtual Region *region();
1.26 +
1.27 + virtual void release(Region *region);
1.28 +};
1.29 +
1.30 +// vim: tabstop=4 expandtab shiftwidth=4