MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

Public Member Functions
MusicBuffer Class Reference

An allocator for MusicChunk objects. More...

`#include <MusicBuffer.hxx>`

## Public Member Functions
| MusicBuffer (unsigned num_chunks)
| Creates a new MusicBuffer object. More...
bool | IsEmptyUnsafe () const
| Check whether the buffer is empty. More...
gcc_pure unsigned | GetSize () const
| Returns the total number of reserved chunks in this buffer. More...
MusicChunk * | Allocate ()
| Allocates a chunk from the buffer. More...
void | Return (MusicChunk *chunk)
| 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 | ( | unsigned | num_chunks | ) |

Creates a new MusicBuffer object.

Parameters

  num_chunks | the number of MusicChunk reserved in this buffer

## Member Function Documentation

MusicChunk* MusicBuffer::Allocate | ( |  | ) |

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

gcc_pure unsigned MusicBuffer::GetSize | ( |  | ) | const
| inline

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.

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.

void MusicBuffer::Return | ( | MusicChunk * | chunk | ) |

Returns a chunk to the buffer.

It can be reused by Allocate() then.

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

- MusicBuffer.hxx