Редагувати

Поділитися через


rts_alloc Class

The rts_alloc class template describes a filter that holds an array of cache instances and determines which instance to use for allocation and deallocation at runtime instead of at compile time.

Syntax

template <class Cache>
class rts_alloc

Parameters

Cache
The type of cache instances contained in the array. It can be cache_chunklist, cache_freelist, or cache_suballoc.

Remarks

This class template holds multiple block allocator instances and determines which instance to use for allocation or deallocation at runtime instead of at compile time. It is used with compilers that cannot compile rebind.

Member functions

Member function Description
allocate Allocates a block of memory.
deallocate Frees a specified number of objects from storage beginning at a specified position.
equals Compares two caches for equality.

Requirements

Header: <allocators>

Namespace: stdext

rts_alloc::allocate

Allocates a block of memory.

void *allocate(std::size_t count);

Parameters

count
The number of elements in the array to be allocated.

Return Value

A pointer to the allocated object.

Remarks

The member function returns caches[_IDX].allocate(count), where the index _IDX is determined by the requested block size count, or, if count is too large, it returns operator new(count). cache, which represents the cache object.

rts_alloc::deallocate

Frees a specified number of objects from storage beginning at a specified position.

void deallocate(void* ptr, std::size_t count);

Parameters

ptr
A pointer to the first object to be deallocated from storage.

count
The number of objects to be deallocated from storage.

Remarks

The member function calls caches[_IDX].deallocate(ptr, count), where the index _IDX is determined by the requested block size count, or, if count is too large, it returns operator delete(ptr).

rts_alloc::equals

Compares two caches for equality.

bool equals(const sync<_Cache>& _Other) const;

Parameters

_Cache
The cache object associated with the filter.

_Other
The cache object to compare for equality.

Remarks

true if the result of caches[0].equals(other.caches[0]); otherwise, false. caches represents the array of cache objects.

See also

ALLOCATOR_DECL
<allocators>