19#include "pw_allocator/allocator.h"
20#include "pw_sync/borrow.h"
21#include "pw_sync/lock_annotations.h"
22#include "pw_sync/no_lock.h"
24namespace pw::allocator {
37template <
typename LockType>
45 allocator_(allocator),
46 borrowable_(allocator_, lock_) {}
69 std::lock_guard lock(lock_);
75 std::lock_guard lock(lock_);
80 bool DoResize(
void* ptr,
size_t new_size)
override {
81 std::lock_guard lock(lock_);
82 return allocator_.
Resize(ptr, new_size);
86 std::lock_guard lock(lock_);
92 std::lock_guard lock(lock_);
98 std::lock_guard lock(lock_);
104 std::lock_guard lock(lock_);
105 return GetInfo(allocator_, info_type, ptr);
110 mutable LockType lock_;
Definition: allocator.h:42
constexpr Allocator()=default
TODO(b/326509341): Remove when downstream consumers migrate.
bool Resize(void *ptr, size_t new_size)
void * Reallocate(void *ptr, Layout new_layout)
void * Allocate(Layout layout)
size_t GetAllocated() const
Definition: allocator.h:277
std::optional< Fragmentation > MeasureFragmentation() const
Returns fragmentation information for the allocator's memory region.
Definition: allocator.h:280
Definition: synchronized_allocator.h:38
size_t DoGetAllocated() const override
Definition: synchronized_allocator.h:91
Result< Layout > DoGetInfo(InfoType info_type, const void *ptr) const override
Definition: synchronized_allocator.h:103
Pointer Borrow() const
Definition: synchronized_allocator.h:64
void DoDeallocate(void *ptr) override
Definition: synchronized_allocator.h:74
bool DoResize(void *ptr, size_t new_size) override
Definition: synchronized_allocator.h:80
void * DoAllocate(Layout layout) override
Definition: synchronized_allocator.h:68
void * DoReallocate(void *ptr, Layout new_layout) override
Definition: synchronized_allocator.h:85
std::optional< Fragmentation > DoMeasureFragmentation() const override
Returns fragmentation information for the allocator's memory region.
Definition: synchronized_allocator.h:97
void Deallocate(void *ptr)
Definition: deallocator.h:314
#define PW_GUARDED_BY(x)
Definition: lock_annotations.h:60