OpenDDS::DCPS::RcObject< T > Class Template Reference

#include <RcObject_T.h>

Inheritance diagram for OpenDDS::DCPS::RcObject< T >:

Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::RcObject< T >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual ~RcObject ()
virtual void _add_ref ()
virtual void _remove_ref ()
long ref_count () const
 This accessor is purely for debugging purposes.

Protected Member Functions

 RcObject (ACE_Allocator *allocator=0)

Private Member Functions

 RcObject (const RcObject &)
RcObjectoperator= (const RcObject &)

Private Attributes

ACE_Atomic_Op< T, long > ref_count_
ACE_Allocatorallocator_

Detailed Description

template<typename T>
class OpenDDS::DCPS::RcObject< T >

Templated reference counting mix-in. A non-DDS specific helper class. The T type is an ace lock type (eg, ACE_SYNCH_MUTEX, ACE_NULL_MUTEX, etc...)

Definition at line 24 of file RcObject_T.h.


Constructor & Destructor Documentation

template<typename T>
virtual OpenDDS::DCPS::RcObject< T >::~RcObject (  )  [inline, virtual]

Definition at line 27 of file RcObject_T.h.

00027 {}

template<typename T>
OpenDDS::DCPS::RcObject< T >::RcObject ( ACE_Allocator allocator = 0  )  [inline, protected]

Definition at line 59 of file RcObject_T.h.

00060     : ref_count_(1), allocator_(allocator)
00061   {}

template<typename T>
OpenDDS::DCPS::RcObject< T >::RcObject ( const RcObject< T > &   )  [private]


Member Function Documentation

template<typename T>
virtual void OpenDDS::DCPS::RcObject< T >::_add_ref (  )  [inline, virtual]

Definition at line 29 of file RcObject_T.h.

Referenced by OpenDDS::DCPS::TransportImpl::configure(), OpenDDS::DCPS::TcpTransport::configure_i(), OpenDDS::DCPS::TcpConnection::open(), OpenDDS::DCPS::TcpSendStrategy::reset(), OpenDDS::DCPS::TcpReceiveStrategy::reset(), OpenDDS::DCPS::TcpConnection::set_datalink(), OpenDDS::DCPS::TcpConnection::set_receive_strategy(), OpenDDS::DCPS::TcpConnection::set_send_strategy(), and OpenDDS::DCPS::TcpDataLink::TcpDataLink().

00029                           {
00030     ++this->ref_count_;
00031   }

template<typename T>
virtual void OpenDDS::DCPS::RcObject< T >::_remove_ref (  )  [inline, virtual]

Definition at line 33 of file RcObject_T.h.

00033                              {
00034     long new_count = --this->ref_count_;
00035 
00036     if (new_count == 0) {
00037       // No need to protect the allocator with a lock since this
00038       // is the last reference to this object, and thus only one
00039       // thread will be doing this final _remove_ref().
00040       ACE_Allocator* allocator = this->allocator_;
00041       this->allocator_ = 0;
00042 
00043       if (allocator) {
00044         this->~RcObject();
00045         allocator->free(this);
00046       } else {
00047         delete this;
00048       }
00049     }
00050   }

template<typename T>
RcObject& OpenDDS::DCPS::RcObject< T >::operator= ( const RcObject< T > &   )  [private]

template<typename T>
long OpenDDS::DCPS::RcObject< T >::ref_count (  )  const [inline]

This accessor is purely for debugging purposes.

Definition at line 53 of file RcObject_T.h.

00053                          {
00054     return this->ref_count_.value();
00055   }


Member Data Documentation

template<typename T>
ACE_Allocator* OpenDDS::DCPS::RcObject< T >::allocator_ [private]

Definition at line 66 of file RcObject_T.h.

template<typename T>
ACE_Atomic_Op<T, long> OpenDDS::DCPS::RcObject< T >::ref_count_ [private]

Definition at line 65 of file RcObject_T.h.


The documentation for this class was generated from the following file:
Generated on Fri Feb 12 20:06:22 2016 for OpenDDS by  doxygen 1.4.7