linuxsampler 2.3.1
LinuxSampler::FrontBuffer< T > Class Template Reference

FrontBuffer object to be accessed by exactly ONE real-time thread. More...

#include <SynchronizedConfig.h>

Inheritance diagram for LinuxSampler::FrontBuffer< T >:
LinuxSampler::SynchronizedConfig< T >::Reader LinuxSampler::Synchronizer< T >

Public Member Functions

 FrontBuffer (BackBuffer< T > &backBuffer)
 
virtual void beginSync () OVERRIDE
 Signal intention to enter a synchronized code block.
 
virtual TsyncedData () OVERRIDE
 Retrieve reference to critical, shared data.
 
virtual void endSync () OVERRIDE
 Signal that the synchronized code block has been left.
 
TLock ()
 Gets the configuration object for use by the real time thread.
 
void Unlock ()
 Unlock the configuration object.
 

Detailed Description

template<class T>
class LinuxSampler::FrontBuffer< T >

FrontBuffer object to be accessed by exactly ONE real-time thread.

A front buffer is designed for real-time access. That is, its methods involved are lock free, that is none of them block the calling thread for a long time.

If you need the front buffer's data to be accessed by multiple real-time threads instead, then you need to create multiple instances of the FrontBuffer object. They would point to the same data, but ensure protection against concurrent access among those real-time threads.

Definition at line 339 of file SynchronizedConfig.h.

Constructor & Destructor Documentation

◆ FrontBuffer()

template<class T >
LinuxSampler::FrontBuffer< T >::FrontBuffer ( BackBuffer< T > &  backBuffer)
inline

Definition at line 341 of file SynchronizedConfig.h.

Member Function Documentation

◆ beginSync()

template<class T >
virtual void LinuxSampler::FrontBuffer< T >::beginSync ( )
inlinevirtual

Signal intention to enter a synchronized code block.

Depending on the actual implementation, this call may block the calling thread until it is safe to actually use the protected data. After this call returns, it is safe for the calling thread to access and modify the shared data. As soon as the thread is done with accessing the shared data, it MUST call endSync().

Returns
the shared protected data

Implements LinuxSampler::Synchronizer< T >.

Definition at line 342 of file SynchronizedConfig.h.

◆ endSync()

template<class T >
virtual void LinuxSampler::FrontBuffer< T >::endSync ( )
inlinevirtual

Signal that the synchronized code block has been left.

Depending on the actual implementation, this call may block the calling thread for a certain amount of time.

Implements LinuxSampler::Synchronizer< T >.

Definition at line 344 of file SynchronizedConfig.h.

◆ Lock()

template<class T >
T & LinuxSampler::SynchronizedConfig< T >::Reader::Lock ( )
inlineinherited

Gets the configuration object for use by the real time thread.

The object is safe to use (read only) until Unlock() is called.

Returns
a reference to the configuration object to be read by the real time thread

Definition at line 77 of file SynchronizedConfig.h.

References LinuxSampler::atomic_thread_fence(), LinuxSampler::atomic< int >::load(), LinuxSampler::memory_order_acquire, LinuxSampler::memory_order_relaxed, LinuxSampler::memory_order_seq_cst, and LinuxSampler::atomic< int >::store().

◆ syncedData()

template<class T >
virtual T & LinuxSampler::FrontBuffer< T >::syncedData ( )
inlinevirtual

Retrieve reference to critical, shared data.

This method shall be called between a beginSync() and endSync() call pair, to be sure that shared data can be accessed safely.

Implements LinuxSampler::Synchronizer< T >.

Definition at line 343 of file SynchronizedConfig.h.

◆ Unlock()

template<class T >
void LinuxSampler::SynchronizedConfig< T >::Reader::Unlock ( )
inlineinherited

Unlock the configuration object.

Unlock() must be called by the real time thread after it has finished reading the configuration object. If the non real time thread is waiting in SwitchConfig() it will be awaken when no real time threads are locked anymore.

Definition at line 92 of file SynchronizedConfig.h.

References LinuxSampler::memory_order_release, and LinuxSampler::atomic< int >::store().


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