VST 3 SDK: RingBuffer< ItemT > Class Template Reference
Author: Steinberg

VST 3 SDK VST 3.8 SDK for developing VST plug-in

Loading...
Searching...
No Matches
Public Member Functions | List of all members
RingBuffer< ItemT > Class Template Reference

Ringbuffer. More...

`#include <ringbuffer.h>`

## Public Member Functions
| RingBuffer (size_t initialNumberOfItems=0) noexcept
| Default constructor.
size_t | size () const noexcept
| size
void | resize (size_t newNumberOfItems) noexcept
| resize
bool | push (ItemT &&item) noexcept
| push a new item into the ringbuffer
bool | push (const ItemT &item) noexcept
| push a new item into the ringbuffer
bool | push (const std::initializer_list< ItemT > &items) noexcept
| push multiple items at once into the ringbuffer
bool | pop (ItemT &item) noexcept
| pop an item out of the ringbuffer

## Detailed Description

template<typename ItemT>
class Steinberg::OneReaderOneWriter::RingBuffer< ItemT >

Ringbuffer.

A ringbuffer supporting one reader and one writer thread

## Constructor & Destructor Documentation

## ◆ RingBuffer()

template<typename ItemT>

RingBuffer | ( | size_t | initialNumberOfItems = 0 | ) |
| inlinenoexcept

Default constructor.

Parameters

  initialNumberOfItems | initial ring buffer size

## Member Function Documentation

## ◆ size()

template<typename ItemT>

size_t size | ( |  | ) | const
| inlinenoexcept

size

Returns
  number of elements the buffer can hold

## ◆ resize()

template<typename ItemT>

void resize | ( | size_t | newNumberOfItems | ) |
| inlinenoexcept

resize

note that you have to make sure that no other thread is reading or writing while calling this method

Parameters

  newNumberOfItems | resize buffer

## ◆ push() [1/3]

template<typename ItemT>

bool push | ( | ItemT && | item | ) |
| inlinenoexcept

push a new item into the ringbuffer

Parameters

  item | to push

Returns
  true on success or false if buffer is full

## ◆ push() [2/3]

template<typename ItemT>

bool push | ( | const ItemT & | item | ) |
| inlinenoexcept

push a new item into the ringbuffer

Parameters

  item | to push

Returns
  true on success or false if buffer is full

## ◆ push() [3/3]

template<typename ItemT>

bool push | ( | const std::initializer_list< ItemT > & | items | ) |
| inlinenoexcept

push multiple items at once into the ringbuffer

if there are insufficient free slots in the ring buffer, no item will be pushed. furthermore, it is guaranteed that the newly added items can only be popped from the buffer after all items have been added.

Parameters

  items | list of items to push

Returns
  true on success or false if there's not enough free space in the buffer

## ◆ pop()

template<typename ItemT>

bool pop | ( | ItemT & | item | ) |
| inlinenoexcept

pop an item out of the ringbuffer

Parameters

  item |

Returns
  true on success or false if buffer is empty

Empty

Copyright © Steinberg Media Technologies GmbH. All Rights Reserved. This documentation is under this license.