BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlma::ConcurrentAllocatorAdapter Class Reference

#include <bdlma_concurrentallocatoradapter.h>

Inheritance diagram for bdlma::ConcurrentAllocatorAdapter:
bslma::Allocator bsl::memory_resource

Public Member Functions

 ConcurrentAllocatorAdapter (bslmt::Mutex *mutex, bslma::Allocator *basicAllocator)
 
 ~ConcurrentAllocatorAdapter () BSLS_KEYWORD_OVERRIDE
 Destroy this thread-enabled allocator adapter.
 
void * allocate (bsls::Types::size_type numBytes) BSLS_KEYWORD_OVERRIDE
 
void deallocate (void *address) BSLS_KEYWORD_OVERRIDE
 
- Public Member Functions inherited from bslma::Allocator
 ~Allocator () BSLS_KEYWORD_OVERRIDE
 
template<class TYPE >
void deleteObject (const TYPE *object)
 
template<class TYPE >
void deleteObjectRaw (const TYPE *object)
 
void deleteObject (bsl::nullptr_t)
 
void deleteObjectRaw (bsl::nullptr_t)
 
- Public Member Functions inherited from bsl::memory_resource
 memory_resource () BSLS_KEYWORD_DEFAULT
 Create this object. Has no effect other than to begin its lifetime.
 
 memory_resource (const memory_resource &) BSLS_KEYWORD_DEFAULT
 
virtual ~memory_resource ()
 Destroy this object. Has no effect other than to end its lifetime.
 
memory_resourceoperator= (const memory_resource &) BSLS_KEYWORD_DEFAULT
 Return a modifiable reference to this object.
 
BSLS_ANNOTATION_NODISCARD void * allocate (size_t bytes, size_t alignment=k_MAX_ALIGN)
 
void deallocate (void *p, size_t bytes, size_t alignment=k_MAX_ALIGN)
 
bool is_equal (const memory_resource &other) const BSLS_KEYWORD_NOEXCEPT
 

Additional Inherited Members

- Public Types inherited from bslma::Allocator
typedef std::size_t size_type
 
- Static Public Member Functions inherited from bslma::Allocator
static void throwBadAlloc ()
 
- Protected Member Functions inherited from bslma::Allocator
void * do_allocate (std::size_t bytes, std::size_t alignment) BSLS_KEYWORD_OVERRIDE
 
void do_deallocate (void *p, std::size_t bytes, std::size_t alignment) BSLS_KEYWORD_OVERRIDE
 
bool do_is_equal (const memory_resource &other) const BSLS_KEYWORD_NOEXCEPT BSLS_KEYWORD_OVERRIDE
 

Detailed Description

This class defines an implementation of the bslma::Allocator protocol that "decorates" (wraps) a concrete bslma::Allocator to ensure thread-safe access to the decorated allocator.

See bdlma_concurrentallocatoradapter

Constructor & Destructor Documentation

◆ ConcurrentAllocatorAdapter()

bdlma::ConcurrentAllocatorAdapter::ConcurrentAllocatorAdapter ( bslmt::Mutex mutex,
bslma::Allocator basicAllocator 
)
inline

Create a thread-enabled allocator adapter that uses the specified mutex to synchronize access to the specified basicAllocator. If basicAllocator is 0, the currently installed default allocator is used.

◆ ~ConcurrentAllocatorAdapter()

bdlma::ConcurrentAllocatorAdapter::~ConcurrentAllocatorAdapter ( )

Member Function Documentation

◆ allocate()

void * bdlma::ConcurrentAllocatorAdapter::allocate ( bsls::Types::size_type  numBytes)
virtual

Return a newly-allocated block of memory of (at least) the specified numBytes. If numBytes is 0, a null pointer is returned with no other effect. If this allocator cannot return the requested number of bytes, then it will throw a bsl::bad_alloc exception in an exception-enabled build, or else will abort the program in a non-exception build. Note that the alignment of the address returned conforms to the platform requirement for any object of the numBytes.

Implements bslma::Allocator.

◆ deallocate()

void bdlma::ConcurrentAllocatorAdapter::deallocate ( void *  address)
virtual

Return the memory at the specified address back to this allocator. If address is 0, this function has no effect. The behavior is undefined unless address was allocated using this allocator and has not since been deallocated.

Implements bslma::Allocator.


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