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< Obj_size, Slab_size, Max_free, Alloc >
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< Obj_size, Slab_size, Max_free, Alloc >
enum  { object_size = Obj_size , slab_size = Slab_size , objects_per_slab = (Slab_size - sizeof(Slab_head)) / object_size , max_free_slabs = Max_free }
 
typedef Alloc< Slab_iSlab_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 346 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 366 of file slab_alloc.

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

References cxx::Slab< Type, Slab_size, Max_free, Alloc >::free().

Referenced by cxx::Slab< Type, Slab_size, Max_free, Alloc >::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: