ROSE 0.11.145.192
Public Member Functions | List of all members
Sawyer::ProxyAllocator< Allocator > Class Template Reference

Description

template<class Allocator>
class Sawyer::ProxyAllocator< Allocator >

Allocator proxy.

Allocators are copied by value when containers are created, which means that each container would normally have its own allocator. However, sometimes, like for pool allocators, performance can be better if multiple containers could share an allocator. An allocator proxy allows containers to share allocators by having the proxy reference the allocator. When the proxy is copied, the new copy continues to point to the original allocator.

Example usage:

Sawyer::PoolAllocator pool; // one pool of memory for all graphs
Graph g1(pool);
Graph g2(pool);
Graph containing user-defined vertices and edges.
Definition Graph.h:634

Definition at line 60 of file DefaultAllocator.h.

#include <Sawyer/DefaultAllocator.h>

Public Member Functions

 ProxyAllocator (Allocator &allocator)
 Constructor.
 
void * allocate (size_t size)
 Allocate memory.
 
void deallocate (void *addr, size_t size)
 Deallocate memory.
 

Constructor & Destructor Documentation

◆ ProxyAllocator()

template<class Allocator >
Sawyer::ProxyAllocator< Allocator >::ProxyAllocator ( Allocator &  allocator)
inline

Constructor.

The constructor stores a reference to the allocator within the new proxy object. All copies of the proxy will refer to the same allocator.

Definition at line 67 of file DefaultAllocator.h.

Member Function Documentation

◆ allocate()

template<class Allocator >
void * Sawyer::ProxyAllocator< Allocator >::allocate ( size_t  size)
inline

Allocate memory.

Allocates new memory by delegating to the underlying allocator.

See also
DefaultAllocator::allocate

Definition at line 74 of file DefaultAllocator.h.

◆ deallocate()

template<class Allocator >
void Sawyer::ProxyAllocator< Allocator >::deallocate ( void *  addr,
size_t  size 
)
inline

Deallocate memory.

Deallocates memory by delegating to the underlying allocator.

See also
DefaultAllocator::deallocate

Definition at line 81 of file DefaultAllocator.h.


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