OpenDDS::DCPS::WeakObject Class Reference

#include <RcObject.h>

Inheritance diagram for OpenDDS::DCPS::WeakObject:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::WeakObject:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 WeakObject (RcObject *ptr)
void _add_ref ()
void _remove_ref ()
RcObjectlock ()
bool set_expire ()

Private Attributes

ACE_Atomic_Op< ACE_SYNCH_MUTEX,
long > 
ref_count_
ACE_SYNCH_MUTEX mx_
RcObject *const ptr_
bool expired_

Detailed Description

Definition at line 22 of file RcObject.h.


Constructor & Destructor Documentation

OpenDDS::DCPS::WeakObject::WeakObject ( RcObject ptr  )  [inline]

Definition at line 25 of file RcObject.h.

00026       : ref_count_(1)
00027       , ptr_(ptr)
00028       , expired_(false)
00029     {
00030     }


Member Function Documentation

void OpenDDS::DCPS::WeakObject::_add_ref ( void   )  [inline]

Definition at line 32 of file RcObject.h.

References ref_count_.

Referenced by OpenDDS::DCPS::RcObject::_get_weak_object(), and OpenDDS::DCPS::WeakRcHandle< DataReaderImpl_T< MessageType > >::WeakRcHandle().

00032                     {
00033       ++this->ref_count_;
00034     }

Here is the caller graph for this function:

void OpenDDS::DCPS::WeakObject::_remove_ref ( void   )  [inline]

Definition at line 36 of file RcObject.h.

References ref_count_.

Referenced by OpenDDS::DCPS::WeakRcHandle< DataReaderImpl_T< MessageType > >::reset(), OpenDDS::DCPS::RcObject::~RcObject(), and OpenDDS::DCPS::WeakRcHandle< DataReaderImpl_T< MessageType > >::~WeakRcHandle().

00036                       {
00037       const long new_count = --this->ref_count_;
00038 
00039       if (new_count == 0) {
00040         delete this;
00041       }
00042     }

Here is the caller graph for this function:

RcObject * OpenDDS::DCPS::WeakObject::lock ( void   )  [inline]

Definition at line 101 of file RcObject.h.

References OpenDDS::DCPS::RcObject::_add_ref(), expired_, mx_, and ptr_.

Referenced by OpenDDS::DCPS::WeakRcHandle< DataReaderImpl_T< MessageType > >::lock().

00102   {
00103     ACE_Guard<ACE_SYNCH_MUTEX> guard(mx_);
00104     if (! expired_) {
00105       ptr_->_add_ref();
00106       return ptr_;
00107     }
00108     return 0;
00109   }

Here is the call graph for this function:

Here is the caller graph for this function:

bool OpenDDS::DCPS::WeakObject::set_expire (  )  [inline]

Definition at line 112 of file RcObject.h.

References expired_, mx_, ptr_, and OpenDDS::DCPS::RcObject::ref_count().

Referenced by OpenDDS::DCPS::RcObject::_remove_ref().

00113   {
00114     ACE_Guard<ACE_SYNCH_MUTEX> guard(mx_);
00115     if (!expired_ && ptr_->ref_count() == 0) {
00116       expired_ = true;
00117     }
00118     return expired_;
00119   }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 50 of file RcObject.h.

Referenced by lock(), and set_expire().

ACE_SYNCH_MUTEX OpenDDS::DCPS::WeakObject::mx_ [private]

Definition at line 48 of file RcObject.h.

Referenced by lock(), and set_expire().

Definition at line 49 of file RcObject.h.

Referenced by lock(), and set_expire().

ACE_Atomic_Op<ACE_SYNCH_MUTEX, long> OpenDDS::DCPS::WeakObject::ref_count_ [private]

Definition at line 47 of file RcObject.h.

Referenced by _add_ref(), and _remove_ref().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1