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

Slab allocator for object of type Type. More...

#include <slab_alloc>

Inheritance diagram for cxx::Slab< Type, Slab_size, Max_free, Alloc >:
Collaboration diagram for cxx::Slab< Type, Slab_size, Max_free, Alloc >:

Public Member Functions

Type * alloc () noexcept
 Allocate an object of type Type.
void free (Type *o) noexcept
 Free the object addressed by o.
Public Member Functions inherited from cxx::Base_slab< sizeof(Type), L4_PAGESIZE, 2, New_allocator >
void * alloc () noexcept
 Allocate a new object.
void free (void *_o) noexcept
 Free the given object (_o).
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 objects which can be allocated before a new empty slab needs to be added to the slab allocator.

Additional Inherited Members

Public Types inherited from cxx::Base_slab< sizeof(Type), L4_PAGESIZE, 2, New_allocator >
typedef New_allocator< Slab_i > Slab_alloc
 Type of the backend allocator.

Detailed Description

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

Slab allocator for object of type Type.

Template Parameters
TypeThe type of the objects to manage.
Slab_sizeSize of a slab.
Max_freeThe maximum number of free slabs.
AllocThe allocator for the slabs.

Definition at line 335 of file slab_alloc.

Member Function Documentation

◆ alloc()

template<typename Type, int Slab_size = L4_PAGESIZE, int Max_free = 2, template< typename A > class Alloc = New_allocator>
Type * cxx::Slab< Type, Slab_size, Max_free, Alloc >::alloc ( )
inlinenoexcept

Allocate an object of type Type.

Returns
A pointer to the object just allocated, or 0 on failure.
Note
The user is responsible for initializing the object.

Definition at line 355 of file slab_alloc.

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

Here is the call graph for this function:

◆ free()

template<typename Type, int Slab_size = L4_PAGESIZE, int Max_free = 2, template< typename A > class Alloc = New_allocator>
void cxx::Slab< Type, Slab_size, Max_free, Alloc >::free ( Type * o)
inlinenoexcept

Free the object addressed by o.

Parameters
oThe pointer to the object to free.
Precondition
The object must have been allocated with this allocator.

Definition at line 366 of file slab_alloc.

References free().

Referenced by free().

Here is the call graph for this function:
Here is the caller graph for this function:

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