Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
FIX::shared_array< T > Class Template Reference

Shared array with atomic reference count. More...

#include <SharedArray.h>

Inheritance diagram for FIX::shared_array< T >:
Inheritance graph
[legend]
Collaboration diagram for FIX::shared_array< T >:
Collaboration graph
[legend]

Public Member Functions

 shared_array ()
 
 shared_array (const shared_array &rhs)
 
 ~shared_array ()
 
shared_arrayoperator= (const shared_array &rhs)
 
std::size_t size () const
 
bool empty () const
 
 operator T* () const
 

Static Public Member Functions

static shared_array create (const std::size_t nSize)
 

Private Member Functions

 shared_array (T *buff, std::size_t nSize, void *pCtr)
 
atomic_countget_counter () const
 
void increment_reference_count () const
 
long decrement_reference_count () const
 
void attach () const
 
void release ()
 

Private Attributes

std::size_t m_size
 
T * m_buffer
 
void * m_pCtr
 

Detailed Description

template<typename T>
class FIX::shared_array< T >

Shared array with atomic reference count.

Definition at line 172 of file SharedArray.h.

Constructor & Destructor Documentation

◆ shared_array() [1/3]

template<typename T>
FIX::shared_array< T >::shared_array ( )
inline

Definition at line 191 of file SharedArray.h.

192  { return m_size; }
193 
194  bool empty() const
195  { return m_buffer == 0; }

◆ shared_array() [2/3]

template<typename T>
FIX::shared_array< T >::shared_array ( const shared_array< T > &  rhs)
inline

Definition at line 197 of file SharedArray.h.

198  { return m_buffer; }
199 
200  //optimized function to allocate storage for buffer and counter object at once
201  static shared_array create(const std::size_t nSize)
202  {

◆ ~shared_array()

template<typename T>
FIX::shared_array< T >::~shared_array ( )
inline

Definition at line 204 of file SharedArray.h.

◆ shared_array() [3/3]

template<typename T>
FIX::shared_array< T >::shared_array ( T *  buff,
std::size_t  nSize,
void *  pCtr 
)
inlineprivate

Definition at line 256 of file SharedArray.h.

257  {
258  if( empty() )
259  return;
260 
261  //free object if reference count has decreased to zero
262  if( decrement_reference_count() == 0)

Member Function Documentation

◆ attach()

template<typename T>
void FIX::shared_array< T >::attach ( ) const
inlineprivate

Definition at line 281 of file SharedArray.h.

◆ create()

template<typename T>
static shared_array FIX::shared_array< T >::create ( const std::size_t  nSize)
inlinestatic

Definition at line 232 of file SharedArray.h.

234  {
235  return reinterpret_cast<atomic_count*>( m_pCtr );
236  }
237 
238  void increment_reference_count() const
239  {
240  atomic_count* counter = get_counter();
241  ++(*counter);
242  }
243 
244  long decrement_reference_count() const
245  {
246  atomic_count* counter = get_counter();
247  return --(*counter);
248  }
249 
250  void attach() const
251  {
252  if( !empty() )

◆ decrement_reference_count()

template<typename T>
long FIX::shared_array< T >::decrement_reference_count ( ) const
inlineprivate

Definition at line 275 of file SharedArray.h.

Referenced by FIX::shared_array< int >::shared_array().

◆ empty()

template<typename T>
bool FIX::shared_array< T >::empty ( ) const
inline

Definition at line 225 of file SharedArray.h.

226  : m_size(nSize)

Referenced by FIX::shared_array< int >::shared_array().

◆ get_counter()

template<typename T>
atomic_count* FIX::shared_array< T >::get_counter ( ) const
inlineprivate

Definition at line 264 of file SharedArray.h.

◆ increment_reference_count()

template<typename T>
void FIX::shared_array< T >::increment_reference_count ( ) const
inlineprivate

Definition at line 269 of file SharedArray.h.

◆ operator T*()

template<typename T>
FIX::shared_array< T >::operator T* ( ) const
inline

Definition at line 228 of file SharedArray.h.

229  {

◆ operator=()

template<typename T>
shared_array& FIX::shared_array< T >::operator= ( const shared_array< T > &  rhs)
inline

Definition at line 207 of file SharedArray.h.

223  :
224 

◆ release()

template<typename T>
void FIX::shared_array< T >::release ( )
inlineprivate

Definition at line 287 of file SharedArray.h.

◆ size()

template<typename T>
std::size_t FIX::shared_array< T >::size ( ) const
inline

Definition at line 222 of file SharedArray.h.

223  :
224 

Member Data Documentation

◆ m_buffer

template<typename T>
T* FIX::shared_array< T >::m_buffer
private

Definition at line 309 of file SharedArray.h.

Referenced by FIX::shared_array< int >::shared_array().

◆ m_pCtr

template<typename T>
void* FIX::shared_array< T >::m_pCtr
private

Definition at line 310 of file SharedArray.h.

Referenced by FIX::shared_array< int >::create().

◆ m_size

template<typename T>
std::size_t FIX::shared_array< T >::m_size
private

Definition at line 308 of file SharedArray.h.

Referenced by FIX::shared_array< int >::shared_array().


The documentation for this class was generated from the following file:
FIX::shared_array::create
static shared_array create(const std::size_t nSize)
Definition: SharedArray.h:232
FIX::shared_array::get_counter
atomic_count * get_counter() const
Definition: SharedArray.h:264
FIX::shared_array::increment_reference_count
void increment_reference_count() const
Definition: SharedArray.h:269
FIX::shared_array::decrement_reference_count
long decrement_reference_count() const
Definition: SharedArray.h:275
FIX::shared_array::m_size
std::size_t m_size
Definition: SharedArray.h:308
FIX::shared_array::m_buffer
T * m_buffer
Definition: SharedArray.h:309
FIX::shared_array::m_pCtr
void * m_pCtr
Definition: SharedArray.h:310
FIX::shared_array::shared_array
shared_array()
Definition: SharedArray.h:191
FIX::shared_array::attach
void attach() const
Definition: SharedArray.h:281
FIX::shared_array::empty
bool empty() const
Definition: SharedArray.h:225

Generated on Thu Apr 23 2020 04:32:03 for QuickFIX by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2001