This is Unofficial EPICS BASE Doxygen Site
epics::pvData::FieldCreate::Helper Struct Reference

Static Public Member Functions

template<typename FLD >
static void cache (const FieldCreate *create, std::tr1::shared_ptr< FLD > &ent)
 

Detailed Description

Definition at line 51 of file FieldCreateFactory.cpp.

Member Function Documentation

template<typename FLD >
static void epics::pvData::FieldCreate::Helper::cache ( const FieldCreate create,
std::tr1::shared_ptr< FLD > &  ent 
)
inlinestatic

Definition at line 53 of file FieldCreateFactory.cpp.

53  {
54  unsigned hash = Field::Helper::hash(ent.get());
55 
56  Lock G(create->mutex);
57  // we examine raw pointers stored in create->cache, which is safe under create->mutex
58 
59  std::pair<cache_t::iterator, cache_t::iterator> itp(create->cache.equal_range(hash));
60  for(; itp.first!=itp.second; ++itp.first) {
61  Field* cent(itp.first->second);
62  FLD* centx(dynamic_cast<FLD*>(cent));
63  if(centx && compare(*centx, *ent)) {
64  try{
65  ent = std::tr1::static_pointer_cast<FLD>(cent->shared_from_this());
66  return;
67  }catch(std::tr1::bad_weak_ptr&){
68  // we're racing destruction.
69  // add a new entry.
70  // Field::~Field is in the process of removing this old one.
71  continue;
72  }
73  }
74  }
75 
76  create->cache.insert(std::make_pair(hash, ent.get()));
77  // cache cleaned from Field::~Field
78  }
shared_ptr< T > static_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
Definition: shared_ptr.hpp:788
static unsigned hash(Field *fld)
bool compare(const Field &a, const Field &b)
Definition: Compare.cpp:26
#define FLD(c, s, f)

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