Loading...
Searching...
No Matches
cxx::Base_slab_static< Obj_size, Slab_size, Max_free, Alloc > Class Template Reference
Small C++ Template Library

Merged slab allocator (allocators for objects of the same size are merged together). More...

`#include <slab_alloc>`

Inheritance diagram for cxx::Base_slab_static< Obj_size, Slab_size, Max_free, Alloc >:
Collaboration diagram for cxx::Base_slab_static< Obj_size, Slab_size, Max_free, Alloc >:

## Public Types

enum | { object_size = Obj_size , slab_size = Slab_size , objects_per_slab = _A::objects_per_slab , max_free_slabs = Max_free }

## Public Member Functions

void * | alloc () noexcept
| Allocate an object.
void | free (void *p) noexcept
| Free the given object (p).
unsigned | total_objects () const noexcept
| Get the total number of objects managed by the slab allocator.
unsigned | free_objects () const noexcept
| Get the number of free objects in the slab allocator.

## Detailed Description

template<int Obj_size, int Slab_size = L4_PAGESIZE, int Max_free = 2, template< typename A > class Alloc = New_allocator>
class cxx::Base_slab_static< Obj_size, Slab_size, Max_free, Alloc >

Merged slab allocator (allocators for objects of the same size are merged together).

Template Parameters

  Obj_size | The size of an object managed by the slab allocator.
  Slab_size | The size of a slab.
  Max_free | The maximum number of free slabs.
  Alloc | The allocator for the slabs.

This slab allocator class is useful for merging slab allocators with the same parameters (equal Obj_size, Slab_size, Max_free, and Alloc parameters) together and share the overhead for the slab caches among all equal-sized objects.

Definition at line 388 of file slab_alloc.

## Member Enumeration Documentation

## anonymous enum

template<int Obj_size, int Slab_size = L4_PAGESIZE, int Max_free = 2, template< typename A > class Alloc = New_allocator>

anonymous enum

Enumerator
object_size | Size of an object.
slab_size | Size of a slab.
objects_per_slab | Number of objects per slab.
max_free_slabs | Maximum number of free slabs.

Definition at line 395 of file slab_alloc.

## Member Function Documentation

## alloc()

template<int Obj_size, int Slab_size = L4_PAGESIZE, int Max_free = 2, template< typename A > class Alloc = New_allocator>

void * cxx::Base_slab_static< Obj_size, Slab_size, Max_free, Alloc >::alloc | ( |  | ) |

inlinenoexcept

Allocate an object.

Note
  The user is responsible for initializing the object.

Definition at line 412 of file slab_alloc.

## free()

template<int Obj_size, int Slab_size = L4_PAGESIZE, int Max_free = 2, template< typename A > class Alloc = New_allocator>

void cxx::Base_slab_static< Obj_size, Slab_size, Max_free, Alloc >::free | ( | void * | p | ) |

inlinenoexcept

Free the given object (p).

Parameters

  p | The pointer to the object to free.

Precondition
  p must be a pointer to an object allocated by this allocator.

Definition at line 420 of file slab_alloc.

## free_objects()

template<int Obj_size, int Slab_size = L4_PAGESIZE, int Max_free = 2, template< typename A > class Alloc = New_allocator>

unsigned cxx::Base_slab_static< Obj_size, Slab_size, Max_free, Alloc >::free_objects | ( |  | ) | const

inlinenoexcept

Get the number of free objects in the slab allocator.

Returns
  The number of free objects in all free and partially used slabs managed by this allocator.

Note
  The value is the merged value for all equal parameterized Base_slab_static instances.

Definition at line 440 of file slab_alloc.

## total_objects()

template<int Obj_size, int Slab_size = L4_PAGESIZE, int Max_free = 2, template< typename A > class Alloc = New_allocator>

unsigned cxx::Base_slab_static< Obj_size, Slab_size, Max_free, Alloc >::total_objects | ( |  | ) | const

inlinenoexcept

Get the total number of objects managed by the slab allocator.

Returns
  The number of objects managed by the allocator (including the free objects).

Note
  The value is the merged value for all equal parameterized Base_slab_static instances.

Definition at line 430 of file slab_alloc.

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

- l4/cxx/slab_alloc