omega_h
Reliable mesh adaptation
Omega_h_pool.hpp
1 #ifndef OMEGA_H_POOL_HPP
2 #define OMEGA_H_POOL_HPP
3 
4 #include <functional>
5 #include <vector>
6 
7 namespace Omega_h {
8 
9 using VoidPtr = void*;
10 using BlockList = std::vector<VoidPtr>;
11 using MallocFunc = std::function<VoidPtr(std::size_t)>;
12 using FreeFunc = std::function<void(VoidPtr, std::size_t)>;
13 
14 struct Pool {
15  Pool(MallocFunc, FreeFunc);
16  ~Pool();
17  Pool(Pool const&) = delete;
18  Pool(Pool&&) = delete;
19  Pool& operator=(Pool const&) = delete;
20  Pool& operator=(Pool&&) = delete;
21  BlockList used_blocks[64];
22  BlockList free_blocks[64];
23  MallocFunc underlying_malloc;
24  FreeFunc underlying_free;
25 };
26 
27 void* allocate(Pool&, std::size_t);
28 void deallocate(Pool&, void*, std::size_t);
29 } // namespace Omega_h
30 
31 #endif
Definition: amr_mpi_test.cpp:6
Definition: Omega_h_pool.hpp:14