OpenDDS  Snapshot(2023/04/28-20:55)
Public Member Functions | Public Attributes | Private Member Functions | List of all members
OpenDDS::DCPS::AddressCache< Key >::ScopedAccess Struct Reference

#include <AddressCache.h>

Collaboration diagram for OpenDDS::DCPS::AddressCache< Key >::ScopedAccess:
Collaboration graph
[legend]

Public Member Functions

 ScopedAccess (AddressCache &cache)
 
 ScopedAccess (AddressCache &cache, const Key &key, bool block=true, const MonotonicTimePoint &now=MonotonicTimePoint::now())
 
 ~ScopedAccess ()
 
AddressCacheEntryvalue ()
 
const AddressCacheEntryvalue () const
 

Public Attributes

ACE_Guard< ACE_Thread_Mutexguard_
 
RcHandle< AddressCacheEntryrch_
 
bool is_new_
 

Private Member Functions

 ScopedAccess ()
 
 ScopedAccess (const ScopedAccess &)
 
ScopedAccessoperator= (const ScopedAccess &)
 

Detailed Description

template<typename Key>
struct OpenDDS::DCPS::AddressCache< Key >::ScopedAccess

Definition at line 100 of file AddressCache.h.

Constructor & Destructor Documentation

◆ ScopedAccess() [1/4]

template<typename Key>
OpenDDS::DCPS::AddressCache< Key >::ScopedAccess::ScopedAccess ( AddressCache cache)
inline

Definition at line 101 of file AddressCache.h.

References if().

102  : guard_(cache.mutex_)
103  , rch_()
104  , is_new_(false)
105 #if defined ACE_HAS_CPP11
106  , non_const_touch_(false)
107 #endif
108  {
109  }
ACE_Guard< ACE_Thread_Mutex > guard_
Definition: AddressCache.h:169
RcHandle< AddressCacheEntry > rch_
Definition: AddressCache.h:170

◆ ScopedAccess() [2/4]

template<typename Key>
OpenDDS::DCPS::AddressCache< Key >::ScopedAccess::ScopedAccess ( AddressCache cache,
const Key &  key,
bool  block = true,
const MonotonicTimePoint now = MonotonicTimePoint::now() 
)
inline

Definition at line 111 of file AddressCache.h.

References OpenDDS::DCPS::AddressCache< Key >::id_map_, if(), OpenDDS::DCPS::AddressCache< Key >::map_, and OpenDDS::DCPS::TimePoint_T< MonotonicClock >::max_value.

112  : guard_(cache.mutex_, block)
113  , rch_()
114  , is_new_(false)
115 #if defined ACE_HAS_CPP11
116  , non_const_touch_(false)
117 #endif
118  {
119  const typename MapType::iterator pos = cache.map_.find(key);
120  if (pos == cache.map_.end()) {
121  rch_ = make_rch<AddressCacheEntry>();
122  cache.map_[key] = rch_;
123  GuidSet set;
124  key.get_contained_guids(set);
125  for (GuidSet::const_iterator it = set.begin(), limit = set.end(); it != limit; ++it) {
126  cache.id_map_[*it].push_back(key);
127  }
128  is_new_ = true;
129  } else {
130  rch_ = pos->second;
131  }
132 
133  if (rch_->expires_ < now) {
134  rch_->addrs_.clear();
136  is_new_ = true;
137  }
138  }
sequence< octet > key
static const TimePoint_T< MonotonicClock > max_value
Definition: TimePoint_T.h:41
ACE_Guard< ACE_Thread_Mutex > guard_
Definition: AddressCache.h:169
RcHandle< AddressCacheEntry > rch_
Definition: AddressCache.h:170

◆ ~ScopedAccess()

template<typename Key>
OpenDDS::DCPS::AddressCache< Key >::ScopedAccess::~ScopedAccess ( )
inline

Definition at line 140 of file AddressCache.h.

141  {
142 #if defined ACE_HAS_CPP11
143  recalculate_hash();
144 #endif
145  }

◆ ScopedAccess() [3/4]

template<typename Key>
OpenDDS::DCPS::AddressCache< Key >::ScopedAccess::ScopedAccess ( )
private

◆ ScopedAccess() [4/4]

template<typename Key>
OpenDDS::DCPS::AddressCache< Key >::ScopedAccess::ScopedAccess ( const ScopedAccess )
private

Member Function Documentation

◆ operator=()

template<typename Key>
ScopedAccess& OpenDDS::DCPS::AddressCache< Key >::ScopedAccess::operator= ( const ScopedAccess )
private

◆ value() [1/2]

template<typename Key>
AddressCacheEntry& OpenDDS::DCPS::AddressCache< Key >::ScopedAccess::value ( void  )
inline

Definition at line 147 of file AddressCache.h.

References OPENDDS_ASSERT.

147  {
149 #if defined ACE_HAS_CPP11
150  non_const_touch_ = true;
151 #endif
152  return *rch_;
153  }
#define OPENDDS_ASSERT(C)
Definition: Definitions.h:72
RcHandle< AddressCacheEntry > rch_
Definition: AddressCache.h:170

◆ value() [2/2]

template<typename Key>
const AddressCacheEntry& OpenDDS::DCPS::AddressCache< Key >::ScopedAccess::value ( void  ) const
inline

Definition at line 155 of file AddressCache.h.

References OPENDDS_ASSERT.

155  {
157  return *rch_;
158  }
#define OPENDDS_ASSERT(C)
Definition: Definitions.h:72
RcHandle< AddressCacheEntry > rch_
Definition: AddressCache.h:170

Member Data Documentation

◆ guard_

template<typename Key>
ACE_Guard<ACE_Thread_Mutex> OpenDDS::DCPS::AddressCache< Key >::ScopedAccess::guard_

Definition at line 169 of file AddressCache.h.

◆ is_new_

template<typename Key>
bool OpenDDS::DCPS::AddressCache< Key >::ScopedAccess::is_new_

Definition at line 171 of file AddressCache.h.

◆ rch_

template<typename Key>
RcHandle<AddressCacheEntry> OpenDDS::DCPS::AddressCache< Key >::ScopedAccess::rch_

Definition at line 170 of file AddressCache.h.


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