L4Re - L4 Runtime Environment
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...

+ 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 () throw ()
 Allocate an object. More...
 
void free (void *p) throw ()
 Free the given object (p). More...
 
unsigned total_objects () const throw ()
 Get the total number of objects managed by the slab allocator. More...
 
unsigned free_objects () const throw ()
 Get the number of free objects in the slab allocator. More...
 

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).

Parameters
Obj_sizeThe size of an object managed by the slab allocator.
Slab_sizeThe size of a slab cache.
Max_freeThe maximum number of free slab caches.
AllocThe allocator for the slab caches.

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 348 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 cache.

objects_per_slab 

number of objects per slab cache.

max_free_slabs 

maximum number of free slab caches.

Definition at line 355 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 ( )
throw (
)
inline

Allocate an object.

Definition at line 365 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)
throw (
)
inline

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 371 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
throw (
)
inline

Get the number of free objects in the slab allocator.

Returns
The number of free objects in all free and partially used slab caches managed by this allocator.
Note
The value is the merged value for all equal parameterized Base_slab_static instances.

Definition at line 389 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
throw (
)
inline

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


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