Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext
utils::page_allocator

An STL allocator which allocates large TLB page memory.If the operating system is configured to allow it, this type of memory is particularly efficient for doing large scale file i/o. This is because the kernel must normally convert the scatter gather buffers you pass into extended scatter gather buffers as the memory you see as contiguous may not, and probably isn't, actually be contiguous in physical memory. Regions returned by this allocator may be allocated contiguously in physical memory and therefore the kernel can pass through your scatter gather buffers unmodified.

Description

A particularly useful combination with this allocator is with the page_sizes() member function of afio_dispatcher. This will return which pages sizes are possible, and which page sizes are enabled for this user. If writing a file copy routine for example, using this allocator with the largest page size as the copy chunk makes a great deal of sense.

Be aware that as soon as the allocation exceeds a large page size, most systems allocate in multiples of the large page size, so if the large page size were 2Mb and you allocate 2Mb + 1 byte, 4Mb is actually consumed.

Synopsis
template<typename T>
class utils::page_allocator
{
  // ...
};
Template parameter(s)

Parameter

Description

typename T

Constructor(s)

Function

Description

Parameters

page_allocator()
template<class U>
page_allocator(const page_allocator< U > & )

const page_allocator< U > &: :

Member Function(s)

Function

Description

Parameters

Returns

size_type max_size()
pointer address(reference x)

reference: x:

const_pointer address(const_reference x)

const_reference: x:

pointer allocate(size_type n, const void * hint = 0)

size_type: n:

const void *: hint:

void deallocate(pointer p, size_type n)

pointer: p:

size_type: n:

template<class U, class... Args>
void construct(U * p, Args &&... args)

U *: p:

Args &&...: args:

template<class U>
void destroy(U * p)

U *: p:

Header

#include <boost/afio/v2/afio.hpp>


PrevUpHomeNext