memory_reservation.hpp
1 
6 #pragma once
7 
9 
10 #include <rapidsmpf/memory/buffer.hpp>
11 #include <rapidsmpf/memory/memory_reservation.hpp>
12 
13 namespace rapidsmpf {
14 
15 class BufferResource;
16 
24  friend class BufferResource;
25 
26  public:
32  ~MemoryReservation() noexcept;
33 
37  void clear() noexcept;
38 
45 
52  MemoryReservation& operator=(MemoryReservation&& o) noexcept;
53 
56  MemoryReservation& operator=(MemoryReservation const&) = delete;
57 
63  [[nodiscard]] constexpr std::size_t size() const noexcept {
64  return size_;
65  }
66 
72  [[nodiscard]] constexpr MemoryType mem_type() const noexcept {
73  return mem_type_;
74  }
75 
81  [[nodiscard]] constexpr BufferResource* br() const noexcept {
82  return br_;
83  }
84 
85  private:
95  constexpr MemoryReservation(MemoryType mem_type, BufferResource* br, std::size_t size)
96  : mem_type_{mem_type}, br_{br}, size_{size} {}
97 
98  private:
99  MemoryType mem_type_;
100  BufferResource* br_;
101  std::size_t size_;
102 };
103 } // namespace rapidsmpf
Class managing buffer resources.
Represents a reservation for future memory allocation.
constexpr BufferResource * br() const noexcept
Get the buffer resource associated with this reservation.
~MemoryReservation() noexcept
Destructor for the memory reservation.
constexpr std::size_t size() const noexcept
Get the remaining size of the reserved memory.
MemoryReservation(MemoryReservation &&o)
Move constructor for MemoryReservation.
void clear() noexcept
Clear the remaining size of the reservation.
constexpr MemoryType mem_type() const noexcept
Get the type of memory associated with this reservation.