forked from stepan-dolgorukov/allocator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathallocator.hxx
More file actions
28 lines (23 loc) · 842 Bytes
/
allocator.hxx
File metadata and controls
28 lines (23 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*!
\file allocator.hxx
\brief Файл содержит объявление класса allocator.
*/
#ifndef allocator_hxx
#define allocator_hxx
#include <cstddef>
#include <mutex>
#include <unordered_map>
class allocator {
private:
std::size_t _size_block{}, _blocks_amount{}, _size_storage{};
std::byte * _storage{};
std::byte * _pointer{};
std::unordered_map< std::byte *, const std::size_t > _left_borders{};
std::mutex _mutex{};
public:
allocator( std::size_t size_block = 1u, std::size_t blocks_amount = 1u );
~allocator();
auto take( std::size_t blocks_amount ) -> std::byte *;
auto release( std::byte * block_pointer ) -> void;
};
#endif