L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
cxx::Base_slab_static< Obj_size, Slab_size, Max_free, Alloc > Class Template Reference

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_sizeThe size of an object managed by the slab allocator.
Slab_sizeThe size of a slab.
Max_freeThe maximum number of free slabs.
AllocThe 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 399 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 406 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 423 of file slab_alloc.

References cxx::Base_slab< Obj_size, Slab_size, Max_free, Alloc >::alloc().

+ Here is the call graph for this function:

◆ 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
pThe pointer to the object to free.
Precondition
p must be a pointer to an object allocated by this allocator.

Definition at line 431 of file slab_alloc.

References cxx::Base_slab< Obj_size, Slab_size, Max_free, Alloc >::free().

+ Here is the call graph for this function:

◆ 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 451 of file slab_alloc.

References cxx::Base_slab< Obj_size, Slab_size, Max_free, Alloc >::free_objects().

+ Here is the call graph for this function:

◆ 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 441 of file slab_alloc.

References cxx::Base_slab< Obj_size, Slab_size, Max_free, Alloc >::total_objects().

+ Here is the call graph for this function:

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