Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QFreeList< T, ConstantsType > Class Template Reference

#include <qfreelist_p.h>

+ Collaboration diagram for QFreeList< T, ConstantsType >:

Public Member Functions

constexpr QFreeList ()
 
 ~QFreeList ()
 
ConstReferenceType at (int x) const
 
ReferenceType operator[] (int x)
 
int next ()
 
void release (int id)
 

Detailed Description

template<typename T, typename ConstantsType = QFreeListDefaultConstants>
class QFreeList< T, ConstantsType >

This is a generic implementation of a lock-free free list. Use next() to get the next free entry in the list, and release(id) when done with the id.

This version is templated and allows having a payload of type T which can be accessed using the id returned by next(). The payload is allocated and deallocated automatically by the free list, but NOT when calling next()/release(). Initialization should be done by code needing it after next() returns. Likewise, cleanup() should happen before calling release(). It is possible to have use 'void' as the payload type, in which case the free list only contains indexes to the next free entry.

The ConstantsType type defaults to QFreeListDefaultConstants above. You can define your custom ConstantsType, see above for details on what needs to be available.

Definition at line 111 of file qfreelist_p.h.

Constructor & Destructor Documentation

◆ QFreeList()

template<typename T , typename ConstantsType >
constexpr QFreeList< T, ConstantsType >::QFreeList ( )
inlineconstexpr

Definition at line 171 of file qfreelist_p.h.

◆ ~QFreeList()

template<typename T , typename ConstantsType >
QFreeList< T, ConstantsType >::~QFreeList ( )
inline

Definition at line 178 of file qfreelist_p.h.

References i.

Member Function Documentation

◆ at()

template<typename T , typename ConstantsType >
QFreeList< T, ConstantsType >::ConstReferenceType QFreeList< T, ConstantsType >::at ( int x) const
inline

Definition at line 185 of file qfreelist_p.h.

◆ next()

template<typename T , typename ConstantsType >
int QFreeList< T, ConstantsType >::next ( )
inline

Definition at line 199 of file qfreelist_p.h.

References at, and Q_ASSERT.

◆ operator[]()

template<typename T , typename ConstantsType >
QFreeList< T, ConstantsType >::ReferenceType QFreeList< T, ConstantsType >::operator[] ( int x)
inline

Definition at line 192 of file qfreelist_p.h.

◆ release()

template<typename T , typename ConstantsType >
void QFreeList< T, ConstantsType >::release ( int id)
inline

Definition at line 230 of file qfreelist_p.h.

References at.


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