v2.0.0
Loading...
Searching...
No Matches
circularbuffer.h File Reference

Bounded single-producer / single-consumer ring buffer used to decouple acquisition threads from processing threads. More...

#include "../utils_global.h"
#include <QPair>
#include <QSemaphore>
#include <QSharedPointer>
#include <Eigen/Core>
Include dependency graph for circularbuffer.h:

Go to the source code of this file.

Classes

class  UTILSLIB::CircularBuffer< T >
 Thread-safe lock-free circular (ring) buffer for producer-consumer data exchange between threads. More...

Namespaces

namespace  UTILSLIB
 Shared utilities (I/O helpers, spectral analysis, layout management, warp algorithms).

Typedefs

typedef CircularBuffer< int > UTILSLIB::CircularBuffer_int
typedef CircularBuffer< short > UTILSLIB::CircularBuffer_short
typedef CircularBuffer< char > UTILSLIB::CircularBuffer_char
typedef CircularBuffer< double > UTILSLIB::CircularBuffer_double
typedef CircularBuffer< QPair< int, int > > UTILSLIB::CircularBuffer_pair_int_int
typedef CircularBuffer< QPair< double, double > > UTILSLIB::CircularBuffer_pair_double_double
typedef CircularBuffer< Eigen::MatrixXd > UTILSLIB::CircularBuffer_Matrix_double
typedef CircularBuffer< Eigen::MatrixXf > UTILSLIB::CircularBuffer_Matrix_float

Detailed Description

Bounded single-producer / single-consumer ring buffer used to decouple acquisition threads from processing threads.

SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2017-2026 MNE-CPP Authors

Author
Christoph Dinh chris.nosp@m.toph.nosp@m..dinh.nosp@m.@mne.nosp@m.-cpp..nosp@m.org; Lorenz Esch loren.nosp@m.z.es.nosp@m.ch@tu.nosp@m.-ilm.nosp@m.enau..nosp@m.de; Juan GPC jgarc.nosp@m.iapr.nosp@m.ieto@.nosp@m.mgh..nosp@m.harva.nosp@m.rd.e.nosp@m.du; Gabriel Motta gabri.nosp@m.elbe.nosp@m.nmott.nosp@m.a@gm.nosp@m.ail.c.nosp@m.om
Since
0.1.0
Date
September 2017

The template UTILSLIB::CircularBuffer wraps a fixed-size T array with two QSemaphore counters — one tracking free slots, one tracking filled slots — so push and pop block (with a configurable timeout) instead of busy-waiting when the buffer is full or empty. This is the building block behind the RtClient / RtCmd transports in COMMUNICATIONLIB and behind every plugin in MNE Scan that streams matrices across thread boundaries.

The implementation is fully header-only so consumers can specialise on Eigen matrices or POD samples without forcing an explicit instantiation in UTILSLIB. pause() lets the downstream consumer drop incoming data temporarily without tearing down the producer thread.

Definition in file circularbuffer.h.