Go to the documentation of this file.
14 #ifndef GRPC_EVENT_ENGINE_MEMORY_ALLOCATOR_H
15 #define GRPC_EVENT_ENGINE_MEMORY_ALLOCATOR_H
23 #include <type_traits>
30 namespace experimental {
41 std::shared_ptr<internal::MemoryAllocatorImpl> allocator)
90 Reservation(std::shared_ptr<internal::MemoryAllocatorImpl> allocator,
94 std::shared_ptr<internal::MemoryAllocatorImpl>
allocator_;
108 template <
typename T,
typename...
Args>
113 class Wrapper final :
public T {
115 explicit Wrapper(std::shared_ptr<internal::MemoryAllocatorImpl> allocator,
118 ~Wrapper()
override {
allocator_->Release(
sizeof(*
this)); }
121 const std::shared_ptr<internal::MemoryAllocatorImpl>
allocator_;
128 template <
typename T,
typename...
Args>
130 return std::unique_ptr<T>(New<T>(std::forward<Args>(
args)...));
140 template <
typename T>
149 template <
typename U>
159 return static_cast<T*
>(::operator
new(
n *
sizeof(
T)));
162 ::operator
delete(p);
188 template <
typename T>
189 class Vector :
public std::vector<T, MemoryAllocator::Container<T>> {
211 #endif // GRPC_EVENT_ENGINE_MEMORY_ALLOCATOR_H
size_t Reserve(MemoryRequest request)
std::shared_ptr< internal::MemoryAllocatorImpl > allocator_
Reservation & operator=(const Reservation &)=delete
Container(const Container< U > &other)
Reservation(std::shared_ptr< internal::MemoryAllocatorImpl > allocator, size_t size)
std::unique_ptr< T > MakeUnique(Args &&... args)
Construct a unique_ptr immediately.
#define T(upbtypeconst, upbtype, ctype, default_value)
MemoryAllocator(std::shared_ptr< internal::MemoryAllocatorImpl > allocator)
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
grpc_slice MakeSlice(MemoryRequest request)
virtual MemoryAllocator CreateMemoryAllocator(absl::string_view name)=0
void deallocate(T *p, size_t n)
MemoryAllocator & operator=(const MemoryAllocator &)=delete
const internal::MemoryAllocatorImpl * get_internal_impl_ptr() const
std::shared_ptr< internal::MemoryAllocatorImpl > allocator_
internal::MemoryAllocatorImpl * get_internal_impl_ptr()
An automatic releasing reservation of memory.
Reservation MakeReservation(MemoryRequest request)
virtual ~MemoryAllocatorFactory()=default
A C++ allocator for containers of T.
MemoryAllocator * underlying_allocator() const
Container(MemoryAllocator *underlying_allocator)
MemoryAllocator * underlying_allocator_
std::enable_if< std::has_virtual_destructor< T >::value, T * >::type New(Args &&... args)
Vector(MemoryAllocator *allocator)
Reservation request - how much memory do we want to allocate?
void Release(size_t n)
Release some bytes that were previously reserved.
grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:35