TSDuck v3.40-3963
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::ResidentBuffer< T > Class Template Reference

Implementation of memory buffer locked in physical memory. More...

#include <tsResidentBuffer.h>

Public Member Functions

 ResidentBuffer (size_t elem_count)
 Constructor, based on required amount of elements.
 
 ~ResidentBuffer ()
 Destructor.
 
T * base () const
 Return base address of the buffer.
 
size_t count () const
 Return the number of elements in the buffer.
 
bool isLocked () const
 Check if the buffer is actually locked.
 
const std::error_code & lockErrorCode () const
 Get error code when not locked.
 

Detailed Description

template<typename T = uint8_t>
class ts::ResidentBuffer< T >

Implementation of memory buffer locked in physical memory.

Template Parameters
TType of the buffer element.

Constructor & Destructor Documentation

◆ ResidentBuffer()

template<typename T >
ts::ResidentBuffer< T >::ResidentBuffer ( size_t  elem_count)

Constructor, based on required amount of elements.

Abort application if memory allocation fails.

Do not abort if memory locking fails. Some operating systems may place limitations on the amount of memory to lock. On DragonFlyBSD, the mlock() system call is reserved to the superuser and memory locking always fails with normal users. Consequently, failing to lock a memory buffer in physical memory is not a real error which prevents the application from working. At worst, there could be performance implications in case of page faults.

Parameters
[in]elem_countNumber of T elements.

Member Function Documentation

◆ isLocked()

template<typename T = uint8_t>
bool ts::ResidentBuffer< T >::isLocked ( ) const
inline

Check if the buffer is actually locked.

Returns
True if the buffer is actually locked, false if locking failed.

◆ lockErrorCode()

template<typename T = uint8_t>
const std::error_code & ts::ResidentBuffer< T >::lockErrorCode ( ) const
inline

Get error code when not locked.

Returns
A constant reference to the system error code when locking failed.

◆ base()

template<typename T = uint8_t>
T * ts::ResidentBuffer< T >::base ( ) const
inline

Return base address of the buffer.

Returns
The address of the first T element in the buffer.

◆ count()

template<typename T = uint8_t>
size_t ts::ResidentBuffer< T >::count ( ) const
inline

Return the number of elements in the buffer.

Returns
The number of T elements in the buffer.

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