Pigweed
Loading...
Searching...
No Matches
pw::allocator::SynchronizedAllocator< LockType > Class Template Reference

#include <synchronized_allocator.h>

Public Member Functions

constexpr SynchronizedAllocator (Allocator &allocator) noexcept
 
- Public Member Functions inherited from pw::Allocator
void * Allocate (Layout layout)
 
template<typename T , int &... ExplicitGuard, typename... Args>
T * New (Args &&... args)
 
template<typename T , int &... ExplicitGuard, typename... Args>
UniquePtr< T > MakeUnique (Args &&... args)
 
bool Resize (void *ptr, size_t new_size)
 
bool Resize (void *ptr, Layout layout, size_t new_size)
 
void * Reallocate (void *ptr, Layout new_layout)
 
void * Reallocate (void *ptr, Layout old_layout, size_t new_size)
 
allocator::AsPmrAllocator as_pmr ()
 
- Public Member Functions inherited from pw::Deallocator
const Capabilitiescapabilities () const
 
bool HasCapability (Capability capability) const
 Returns whether a given capabilityis enabled for this object.
 
void Deallocate (void *ptr)
 
void Deallocate (void *ptr, Layout layout)
 
template<typename T >
void Delete (T *ptr)
 
StatusWithSize GetCapacity () const
 
bool IsEqual (const Deallocator &other) const
 

Additional Inherited Members

- Public Types inherited from pw::Deallocator
using Capabilities = allocator::Capabilities
 
using Capability = allocator::Capability
 
using Layout = allocator::Layout
 
- Protected Member Functions inherited from pw::Allocator
constexpr Allocator ()=default
 TODO(b/326509341): Remove when downstream consumers migrate.
 
constexpr Allocator (const Capabilities &capabilities)
 
- Protected Member Functions inherited from pw::Deallocator
constexpr Deallocator ()=default
 TODO(b/326509341): Remove when downstream consumers migrate.
 
constexpr Deallocator (const Capabilities &capabilities)
 
template<typename T >
UniquePtr< T > WrapUnique (T *ptr)
 

Detailed Description

template<typename LockType>
class pw::allocator::SynchronizedAllocator< LockType >

Wraps an Allocator with a lock to synchronize access.

Depending on the LockType, this object may be thread- and/or interrupt- safe. For example, SynchronizedAllocator<pw::sync::Mutex> is thread-safe, while SynchronizedAllocator<pw::sync::InterruptSpinLock> is thread- and interrupt-safe.

Template Parameters
LockTypeThe type of the lock used to synchronize allocator access. Must be default-constructible.

The documentation for this class was generated from the following file: