Block-Structured AMR Software Framework
AMReX_GpuElixir.H
Go to the documentation of this file.
1 #ifndef AMREX_GPUELIXIR_H_
2 #define AMREX_GPUELIXIR_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_Arena.H>
6 #include <AMReX_Vector.H>
7 #include <utility>
8 
9 namespace amrex {
10 namespace Gpu {
11 
12 class Elixir
13 {
14 public:
15 
16  Elixir () noexcept = default;
17 
18  Elixir (void* p, Arena* arena) noexcept : m_pa({std::make_pair(p,arena)}) {}
19 
20  Elixir (Elixir const&) = delete;
21  Elixir& operator= (Elixir const&) = delete;
22 
23  Elixir (Elixir && rhs) noexcept
24  : m_pa(std::move(rhs.m_pa))
25  {
26  rhs.m_pa.clear();
27  }
28 
29  Elixir& operator= (Elixir && rhs) noexcept
30  {
31  clear();
32  m_pa = std::move(rhs.m_pa);
33  rhs.m_pa.clear();
34  return *this;
35  }
36 
37  void append (Elixir rhs) noexcept
38  {
39  m_pa.insert(m_pa.end(), rhs.m_pa.begin(), rhs.m_pa.end());
40  rhs.m_pa.clear();
41  }
42 
43  ~Elixir () { clear(); }
44 
45  void clear () noexcept;
46 
47 private:
48  Vector<std::pair<void*,Arena*> > m_pa;
49 };
50 
51 }
52 
53 using Gpu::Elixir;
54 }
55 
56 #endif
A virtual base class for objects that manage their own dynamic memory allocation.
Definition: AMReX_Arena.H:100
Definition: AMReX_GpuElixir.H:13
void clear() noexcept
Definition: AMReX_GpuElixir.cpp:35
Elixir(Elixir &&rhs) noexcept
Definition: AMReX_GpuElixir.H:23
Vector< std::pair< void *, Arena * > > m_pa
Definition: AMReX_GpuElixir.H:48
Elixir & operator=(Elixir const &)=delete
Elixir() noexcept=default
~Elixir()
Definition: AMReX_GpuElixir.H:43
void append(Elixir rhs) noexcept
Definition: AMReX_GpuElixir.H:37
Elixir(Elixir const &)=delete
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition: AMReX_Vector.H:27
Definition: AMReX_Amr.cpp:49