ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
page_allocator.h
Go to the documentation of this file.
1#ifndef PAGE_ALLOCATOR_H
2#define PAGE_ALLOCATOR_H
3
4#include <vector>
5
7{
8public:
9 enum { default_pgsize = 1024 };
10
11 PageAllocator() = default;
12 PageAllocator(const PageAllocator&) = delete;
16
17 void initialize(int pgsize);
18 int* allocate(int n);
19 void reset();
20 int get_pgsize() const;
21
22private:
23 struct Page
24 {
25 int capacity = 0;
26 int offset = 0;
27 std::vector<int> data;
28 };
29
30 std::vector<Page> pages_;
32
33 void new_page_();
34};
35
36#endif // PAGE_ALLOCATOR_H
void new_page_()
Definition page_allocator.cpp:68
int * allocate(int n)
Definition page_allocator.cpp:18
void reset()
Definition page_allocator.cpp:52
void initialize(int pgsize)
Definition page_allocator.cpp:7
PageAllocator & operator=(PageAllocator &&)=default
PageAllocator()=default
std::vector< Page > pages_
Definition page_allocator.h:30
@ default_pgsize
Definition page_allocator.h:9
PageAllocator & operator=(const PageAllocator &)=delete
PageAllocator(const PageAllocator &)=delete
PageAllocator(PageAllocator &&)=default
int get_pgsize() const
Definition page_allocator.cpp:63
int pgsize_
Definition page_allocator.h:31
Definition page_allocator.h:24
int capacity
Definition page_allocator.h:25
std::vector< int > data
Definition page_allocator.h:27
int offset
Definition page_allocator.h:26