Ardour  9.0-pre0-582-g084a23a80d
RCUManager< T > Class Template Referenceabstract

#include <rcu.h>

Inheritance diagram for RCUManager< T >:
[legend]

Public Member Functions

 RCUManager (T *object_to_be_managed)
 
virtual ~RCUManager ()
 
std::shared_ptr< T const > reader () const
 
virtual std::shared_ptr< T > write_copy ()=0
 
virtual bool update (std::shared_ptr< T > new_value)=0
 

Protected Types

typedef std::shared_ptr< T > * PtrToSharedPtr
 

Protected Member Functions

bool active_read () const
 

Protected Attributes

std::atomic< PtrToSharedPtrmanaged_object
 

Private Attributes

std::atomic< int > _active_reads
 

Detailed Description

template<class T>
class RCUManager< T >

An RCUManager is an object which takes over management of a pointer to another object.

It provides three key methods:

  • reader() : obtains a shared pointer to the managed object that may be used for reading, without synchronization
  • write_copy() : obtains a shared pointer to the object that may be used for writing/modification
  • update() : accepts a shared pointer to a (presumed) modified instance of the object and causes all future reader() and write_copy() calls to use that instance.

Any existing users of the value returned by reader() can continue to use their copy even as a write_copy()/update() takes place. The RCU manager will manage the various instances of "the managed object" in a way that is transparent to users of the manager and managed object.

Definition at line 52 of file rcu.h.

Member Typedef Documentation

◆ PtrToSharedPtr

template<class T >
typedef std::shared_ptr<T>* RCUManager< T >::PtrToSharedPtr
protected

Definition at line 101 of file rcu.h.

Constructor & Destructor Documentation

◆ RCUManager()

template<class T >
RCUManager< T >::RCUManager ( T *  object_to_be_managed)
inline

Definition at line 55 of file rcu.h.

◆ ~RCUManager()

template<class T >
virtual RCUManager< T >::~RCUManager ( )
inlinevirtual

Definition at line 61 of file rcu.h.

Member Function Documentation

◆ active_read()

template<class T >
bool RCUManager< T >::active_read ( ) const
inlineprotected

Definition at line 104 of file rcu.h.

◆ reader()

template<class T >
std::shared_ptr<T const> RCUManager< T >::reader ( ) const
inline

Definition at line 69 of file rcu.h.

◆ update()

template<class T >
virtual bool RCUManager< T >::update ( std::shared_ptr< T >  new_value)
pure virtual

Implemented in SerializedRCUManager< T >.

◆ write_copy()

Member Data Documentation

◆ _active_reads

template<class T >
std::atomic<int> RCUManager< T >::_active_reads
mutableprivate

Definition at line 109 of file rcu.h.

◆ managed_object

template<class T >
std::atomic<PtrToSharedPtr> RCUManager< T >::managed_object
protected

Definition at line 102 of file rcu.h.


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