49 std::shared_ptr<BlocksContainer<BlockSize, MaxNumBlocks>>
105 blocks = other.blocks;
110 template <
typename U,
int BS,
int MNB>
187 std::ofstream logfile;
188 logfile.open(logfile_dir, std::ios::app);
189 logfile <<
"#####################################################\n";
190 logfile <<
"Halloc Allocator State:\n";
191 blocks->log_container_state(logfile);
192 logfile <<
"#####################################################\n";
211template <
typename T,
int BlockSize,
int MaxNumBlocks>
213 : blocks(std::make_shared<
BlocksContainer<BlockSize, MaxNumBlocks>>()) {
232template <
typename T,
int BlockSize,
int MaxNumBlocks>
234 return static_cast<T*
>(blocks->allocate(count *
sizeof(T)));
252template <
typename T,
int BlockSize,
int MaxNumBlocks>
254 blocks->deallocate(ptr, count *
sizeof(T));
269template <
typename T,
int BlockSize,
int MaxNumBlocks>
Container managing multiple memory blocks for large-scale allocations.
const int DEFAULT_MAX_NUM_BLOCKS
Default max blocks: 1.
Definition Halloc.hpp:22
const int DEFAULT_BLOCK_SIZE
Default block size: 128 MB.
Definition Halloc.hpp:21
Manages multiple memory blocks for scalable allocation.
Definition BlocksContainer.hpp:36
Type-safe allocator using Red-Black tree for best-fit allocation.
Definition Halloc.hpp:47
bool operator!=(const Halloc &other) const
Inequality comparison.
Definition Halloc.hpp:169
void log_container_state(const char *logfile_dir) const
Logs the current state of the container to a file.
Definition Halloc.hpp:186
void deallocate(T *ptr, std::size_t count)
Deallocates memory previously allocated for 'count' objects.
Definition Halloc.hpp:253
~Halloc()
Destructor - releases all blocks back to the OS.
Definition Halloc.hpp:270
std::size_t size_type
Type for sizes.
Definition Halloc.hpp:60
T value_type
Type of allocated objects.
Definition Halloc.hpp:55
T & reference
Reference to value_type.
Definition Halloc.hpp:58
T * pointer
Pointer to value_type.
Definition Halloc.hpp:56
friend class Halloc
Definition Halloc.hpp:111
std::ptrdiff_t difference_type
Type for pointer differences.
Definition Halloc.hpp:61
Halloc(const Halloc &other)
Copy constructor - shares underlying BlocksContainer.
Definition Halloc.hpp:85
const T & const_reference
Const reference to value_type.
Definition Halloc.hpp:59
Halloc & operator=(const Halloc &other)
Assignment operator.
Definition Halloc.hpp:104
bool operator==(const Halloc &other) const
Equality comparison - checks if allocators share same container.
Definition Halloc.hpp:161
Halloc(const Halloc< U, BlockSize, MaxNumBlocks > &other)
Rebind copy constructor - shares BlocksContainer across types.
Definition Halloc.hpp:97
const T * const_pointer
Const pointer to value_type.
Definition Halloc.hpp:57
T * allocate(std::size_t count)
Allocates memory for 'count' objects of type T.
Definition Halloc.hpp:233
Rebind allocator to allocate different type U.
Definition Halloc.hpp:70