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_);
83 bool DoResize(
void* ptr,
size_t new_size)
override {
84 std::lock_guard lock(lock_);
85 return allocator_.
Resize(ptr, new_size);
89 std::lock_guard lock(lock_);
95 std::lock_guard lock(lock_);
101 std::lock_guard lock(lock_);
102 return GetInfo(allocator_, info_type, ptr);
106 mutable LockType lock_;
Definition: allocator.h:36
constexpr Allocator()=default
TODO(b/326509341): Remove when downstream consumers migrate.
bool Resize(void *ptr, size_t new_size)
Definition: allocator.h:287
void * Reallocate(void *ptr, Layout new_layout)
Definition: allocator.h:321
void * Allocate(Layout layout)
Definition: allocator.h:44
size_t GetAllocated() const
Definition: allocator.h:346
Definition: synchronized_allocator.h:38
void DoDeallocate(void *ptr, Layout) override
Definition: synchronized_allocator.h:80
size_t DoGetAllocated() const override
Definition: synchronized_allocator.h:94
Result< Layout > DoGetInfo(InfoType info_type, const void *ptr) const override
Definition: synchronized_allocator.h:100
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:83
void * DoAllocate(Layout layout) override
Definition: synchronized_allocator.h:68
void * DoReallocate(void *ptr, Layout new_layout) override
Definition: synchronized_allocator.h:88
void Deallocate(void *ptr)
Definition: deallocator.h:60
#define PW_GUARDED_BY(x)
Definition: lock_annotations.h:60