MPD  0.20.18
Public Member Functions
MusicBuffer Class Reference

An allocator for MusicChunk objects. More...

#include <MusicBuffer.hxx>

Public Member Functions

 MusicBuffer (unsigned num_chunks) noexcept
 Creates a new MusicBuffer object. More...
 
bool IsEmptyUnsafe () const
 Check whether the buffer is empty. More...
 
gcc_pure unsigned GetSize () const noexcept
 Returns the total number of reserved chunks in this buffer. More...
 
MusicChunkAllocate () noexcept
 Allocates a chunk from the buffer. More...
 
void Return (MusicChunk *chunk) noexcept
 Returns a chunk to the buffer. More...
 

Detailed Description

An allocator for MusicChunk objects.

Definition at line 31 of file MusicBuffer.hxx.

Constructor & Destructor Documentation

◆ MusicBuffer()

MusicBuffer::MusicBuffer ( unsigned  num_chunks)
noexcept

Creates a new MusicBuffer object.

Parameters
num_chunksthe number of MusicChunk reserved in this buffer

Member Function Documentation

◆ Allocate()

MusicChunk* MusicBuffer::Allocate ( )
noexcept

Allocates a chunk from the buffer.

When it is not used anymore, call Return().

Returns
an empty chunk or nullptr if there are no chunks available

◆ GetSize()

gcc_pure unsigned MusicBuffer::GetSize ( ) const
inlinenoexcept

Returns the total number of reserved chunks in this buffer.

This is the same value which was passed to the constructor music_buffer_new().

Definition at line 63 of file MusicBuffer.hxx.

◆ IsEmptyUnsafe()

bool MusicBuffer::IsEmptyUnsafe ( ) const
inline

Check whether the buffer is empty.

This call is not protected with the mutex, and may only be used while this object is inaccessible to other threads.

Definition at line 52 of file MusicBuffer.hxx.

◆ Return()

void MusicBuffer::Return ( MusicChunk chunk)
noexcept

Returns a chunk to the buffer.

It can be reused by Allocate() then.


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