OpenDDS::DCPS::InstanceState Class Reference

manage the states of a received data instance. More...

#include <InstanceState.h>

Collaboration diagram for OpenDDS::DCPS::InstanceState:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 InstanceState (DataReaderImpl *reader, ACE_Recursive_Thread_Mutex &lock, DDS::InstanceHandle_t handle)
 Constructor.
virtual ~InstanceState ()
 Destructor.
void sample_info (DDS::SampleInfo &si, const ReceivedDataElement *de)
 Populate the SampleInfo structure.
DDS::InstanceStateKind instance_state () const
 Access instance state.
DDS::ViewStateKind view_state () const
 Access view state.
size_t disposed_generation_count () const
 Access disposed generation count.
size_t no_writers_generation_count () const
 Access no writers generation count.
bool dispose_was_received (const PublicationId &writer_id)
bool unregister_was_received (const PublicationId &writer_id)
void data_was_received (const PublicationId &writer_id)
 Data sample received for this instance.
void lively (const PublicationId &writer_id)
 LIVELINESS message received for this DataWriter.
void accessed ()
 A read or take operation has been performed on this instance.
bool most_recent_generation (ReceivedDataElement *item) const
bool empty (bool value)
 DataReader has become empty. Returns true if the instance was released.
void schedule_pending ()
 Schedule a pending release of resources.
void schedule_release ()
 Schedule an immediate release of resources.
void cancel_release ()
 Cancel a scheduled or pending release of resources.
bool release_if_empty ()
void release ()
 Remove the instance immediately.
void writer_became_dead (const PublicationId &writer_id, int num_alive_writers, const ACE_Time_Value &when)
 tell this instance when a DataWriter transitions to NOT_ALIVE
DataReaderImpldata_reader () const
virtual int handle_timeout (const ACE_Time_Value &current_time, const void *arg)
void set_owner (const PublicationId &owner)
PublicationIdget_owner ()
bool is_exclusive () const
bool registered ()
void registered (bool flag)
bool is_last (const PublicationId &pub)
bool no_writer () const
void reset_ownership (::DDS::InstanceHandle_t instance)
DDS::InstanceHandle_t instance_handle () const

Private Attributes

ACE_Recursive_Thread_Mutex & lock_
DDS::InstanceStateKind instance_state_
DDS::ViewStateKind view_state_
size_t disposed_generation_count_
size_t no_writers_generation_count_
bool empty_
bool release_pending_
long release_timer_id_
DataReaderImplreader_
DDS::InstanceHandle_t handle_
RepoIdSet writers_
PublicationId owner_
bool exclusive_
bool registered_

Detailed Description

manage the states of a received data instance.

Provide a mechanism to manage the view state and instance state values for an instance contained within a DataReader. The instance_state and view_state are managed by this class. Accessors are provided to query the current value of each of these states.

Definition at line 39 of file InstanceState.h.


Constructor & Destructor Documentation

OpenDDS::DCPS::InstanceState::InstanceState ( DataReaderImpl reader,
ACE_Recursive_Thread_Mutex &  lock,
DDS::InstanceHandle_t  handle 
)

Constructor.

Definition at line 22 of file InstanceState.cpp.

00025   : lock_(lock),
00026     instance_state_(0),
00027     view_state_(0),
00028     disposed_generation_count_(0),
00029     no_writers_generation_count_(0),
00030     empty_(true),
00031     release_pending_(false),
00032     release_timer_id_(-1),
00033     reader_(reader),
00034     handle_(handle),
00035     owner_(GUID_UNKNOWN),
00036 #ifndef OPENDDS_NO_OWNERSHIP_KIND_EXCLUSIVE
00037     exclusive_(reader->qos_.ownership.kind == ::DDS::EXCLUSIVE_OWNERSHIP_QOS),
00038 #endif
00039     registered_ (false)
00040 {}

OpenDDS::DCPS::InstanceState::~InstanceState (  )  [virtual]

Destructor.

Definition at line 42 of file InstanceState.cpp.

References cancel_release(), OpenDDS::DCPS::DataReaderImpl::ownership_manager(), reader_, registered_, and OpenDDS::DCPS::OwnershipManager::remove_instance().

00043 {
00044   cancel_release();
00045 #ifndef OPENDDS_NO_OWNERSHIP_KIND_EXCLUSIVE
00046   if (registered_) {
00047     OwnershipManager* om = reader_->ownership_manager();
00048     if (om) om->remove_instance(this);
00049   }
00050 #endif
00051 }


Member Function Documentation

ACE_INLINE void OpenDDS::DCPS::InstanceState::accessed (  ) 

A read or take operation has been performed on this instance.

Definition at line 20 of file InstanceState.inl.

References DDS::ANY_VIEW_STATE, DDS::NOT_NEW_VIEW_STATE, and view_state_.

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

00021 {
00022   ACE_GUARD(ACE_Recursive_Thread_Mutex,
00023             guard, this->lock_);
00024   //
00025   // Manage the view state due to data access here.
00026   //
00027   if (this->view_state_ & DDS::ANY_VIEW_STATE) {
00028     this->view_state_ = DDS::NOT_NEW_VIEW_STATE ;
00029   }
00030 }

void OpenDDS::DCPS::InstanceState::cancel_release (  ) 

Cancel a scheduled or pending release of resources.

Definition at line 229 of file InstanceState.cpp.

References OpenDDS::DCPS::DataReaderImpl::get_reactor(), reader_, release_pending_, and release_timer_id_.

Referenced by data_was_received(), lively(), OpenDDS::DCPS::DataReaderImpl_T< MessageType >::purge_data(), schedule_release(), and ~InstanceState().

00230 {
00231   this->release_pending_ = false;
00232 
00233   if (this->release_timer_id_ != -1) {
00234     ACE_Reactor_Timer_Interface* reactor = this->reader_->get_reactor();
00235     reactor->cancel_timer(this->release_timer_id_);
00236 
00237     this->release_timer_id_ = -1;
00238   }
00239 }

ACE_INLINE OpenDDS::DCPS::DataReaderImpl * OpenDDS::DCPS::InstanceState::data_reader (  )  const

Definition at line 13 of file InstanceState.inl.

References reader_.

00014 {
00015   return reader_;
00016 }

ACE_INLINE void OpenDDS::DCPS::InstanceState::data_was_received ( const PublicationId writer_id  ) 

Data sample received for this instance.

Definition at line 68 of file InstanceState.inl.

References DDS::ALIVE_INSTANCE_STATE, cancel_release(), disposed_generation_count_, instance_state_, DDS::NEW_VIEW_STATE, no_writers_generation_count_, DDS::NOT_ALIVE_DISPOSED_INSTANCE_STATE, DDS::NOT_ALIVE_INSTANCE_STATE, DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE, DDS::NOT_NEW_VIEW_STATE, view_state_, and writers_.

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

00069 {
00070   ACE_GUARD(ACE_Recursive_Thread_Mutex,
00071             guard, this->lock_);
00072   cancel_release();
00073 
00074   //
00075   // Update the view state here, since only sample data received affects
00076   // this state value.  Then manage the data sample only transistions
00077   // here.  Let the lively() method manage the other transitions.
00078   //
00079   writers_.insert(writer_id);
00080 
00081   switch (this->view_state_) {
00082   case DDS::NEW_VIEW_STATE:
00083     break ; // No action.
00084 
00085   case DDS::NOT_NEW_VIEW_STATE:
00086 
00087     if (this->instance_state_ & DDS::NOT_ALIVE_INSTANCE_STATE) {
00088       this->view_state_ = DDS::NEW_VIEW_STATE ;
00089     }
00090 
00091     break ;
00092 
00093   default:
00094     this->view_state_ = DDS::NEW_VIEW_STATE ;
00095     break ;
00096   }
00097 
00098   switch (this->instance_state_) {
00099   case DDS::NOT_ALIVE_DISPOSED_INSTANCE_STATE:
00100     ++this->disposed_generation_count_;
00101     break ;
00102 
00103   case DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE:
00104     ++this->no_writers_generation_count_;
00105     break ;
00106 
00107   default:
00108     break ;
00109   }
00110 
00111   this->instance_state_ = DDS::ALIVE_INSTANCE_STATE ;
00112 }

bool OpenDDS::DCPS::InstanceState::dispose_was_received ( const PublicationId writer_id  ) 

DISPOSE message received for this instance. Return flag indicates whether the instance state was changed. This flag is used by concreate DataReader to determine whether it should notify listener. If state is not changed, the dispose message is ignored.

Definition at line 105 of file InstanceState.cpp.

References DDS::ALIVE_INSTANCE_STATE, DDS::NOT_ALIVE_DISPOSED_INSTANCE_STATE, schedule_release(), and writers_.

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

00106 {
00107   ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex,
00108                    guard, this->lock_, false);
00109 
00110   writers_.erase(writer_id);
00111 
00112   //
00113   // Manage the instance state on disposal here.
00114   //
00115   // If disposed by owner then the owner is not re-elected, it can
00116   // resume if the writer sends message again.
00117   if (this->instance_state_ & DDS::ALIVE_INSTANCE_STATE) {
00118 #ifndef OPENDDS_NO_OWNERSHIP_KIND_EXCLUSIVE
00119     if (! this->exclusive_
00120       || this->reader_->owner_manager_->is_owner (this->handle_, writer_id)) {
00121 #endif
00122       this->instance_state_ = DDS::NOT_ALIVE_DISPOSED_INSTANCE_STATE;
00123       schedule_release();
00124       return true;
00125 #ifndef OPENDDS_NO_OWNERSHIP_KIND_EXCLUSIVE
00126     }
00127 #endif
00128   }
00129 
00130   return false;
00131 }

ACE_INLINE size_t OpenDDS::DCPS::InstanceState::disposed_generation_count (  )  const

Access disposed generation count.

Definition at line 55 of file InstanceState.inl.

References disposed_generation_count_.

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

00056 {
00057   return disposed_generation_count_ ;
00058 }

ACE_INLINE bool OpenDDS::DCPS::InstanceState::empty ( bool  value  ) 

DataReader has become empty. Returns true if the instance was released.

Definition at line 137 of file InstanceState.inl.

References release_if_empty().

Referenced by OpenDDS::DCPS::ReceivedDataElementList::add(), and OpenDDS::DCPS::ReceivedDataElementList::remove().

00138 {
00139   //
00140   // Manage the instance state due to the DataReader becoming empty
00141   // here.
00142   //
00143   if ((this->empty_ = value) && this->release_pending_) {
00144     return release_if_empty();
00145   } else {
00146     return false;
00147   }
00148 }

OpenDDS::DCPS::PublicationId & OpenDDS::DCPS::InstanceState::get_owner (  ) 

Definition at line 267 of file InstanceState.cpp.

References owner_.

Referenced by OpenDDS::DCPS::DataReaderImpl::filter_instance().

00268 {
00269   return this->owner_;
00270 }

int OpenDDS::DCPS::InstanceState::handle_timeout ( const ACE_Time_Value &  current_time,
const void *  arg 
) [virtual]

Definition at line 89 of file InstanceState.cpp.

References OpenDDS::DCPS::DCPS_debug_level, and release().

00091 {
00092   if (OpenDDS::DCPS::DCPS_debug_level > 0) {
00093     ACE_DEBUG((LM_NOTICE,
00094                ACE_TEXT("(%P|%t) NOTICE:")
00095                ACE_TEXT(" InstanceState::handle_timeout:")
00096                ACE_TEXT(" autopurging samples with instance handle 0x%x!\n"),
00097                this->handle_));
00098   }
00099   this->release();
00100 
00101   return 0;
00102 }

DDS::InstanceHandle_t OpenDDS::DCPS::InstanceState::instance_handle (  )  const [inline]

Definition at line 131 of file InstanceState.h.

Referenced by OpenDDS::DCPS::OwnershipManager::remove_instance().

00131 { return handle_; }

ACE_INLINE DDS::InstanceStateKind OpenDDS::DCPS::InstanceState::instance_state (  )  const

Access instance state.

Definition at line 42 of file InstanceState.inl.

References instance_state_.

Referenced by OpenDDS::DCPS::DataReaderImpl_T< MessageType >::read_instance_i(), and OpenDDS::DCPS::DataReaderImpl_T< MessageType >::take_instance_i().

00043 {
00044   return this->instance_state_ ;
00045 }

bool OpenDDS::DCPS::InstanceState::is_exclusive (  )  const

Definition at line 273 of file InstanceState.cpp.

References exclusive_.

Referenced by OpenDDS::DCPS::RequestedDeadlineWatchdog::execute().

00274 {
00275   return this->exclusive_;
00276 }

ACE_INLINE bool OpenDDS::DCPS::InstanceState::is_last ( const PublicationId pub  ) 

Definition at line 153 of file InstanceState.inl.

Referenced by OpenDDS::DCPS::DataReaderImpl::data_received().

00154 {
00155   ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex,
00156                    guard, this->lock_, false);
00157 
00158   return (this->writers_.size () == 1) && *(this->writers_.begin ()) == pub;
00159 }

ACE_INLINE void OpenDDS::DCPS::InstanceState::lively ( const PublicationId writer_id  ) 

LIVELINESS message received for this DataWriter.

Definition at line 116 of file InstanceState.inl.

References DDS::ALIVE_INSTANCE_STATE, cancel_release(), instance_state_, no_writers_generation_count_, DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE, and writers_.

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

00117 {
00118   ACE_GUARD(ACE_Recursive_Thread_Mutex,
00119             guard, this->lock_);
00120 
00121   //
00122   // Manage transisitions in the instance state that do not require a
00123   // data sample, but merely the notion of liveliness.
00124   //
00125   writers_.insert(writer_id);
00126 
00127   if (this->instance_state_ == DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE) {
00128     cancel_release(); // cancel unregister
00129 
00130     this->no_writers_generation_count_++ ;
00131     this->instance_state_ = DDS::ALIVE_INSTANCE_STATE ;
00132   }
00133 }

ACE_INLINE bool OpenDDS::DCPS::InstanceState::most_recent_generation ( ReceivedDataElement item  )  const

Definition at line 34 of file InstanceState.inl.

References disposed_generation_count_, OpenDDS::DCPS::ReceivedDataElement::disposed_generation_count_, no_writers_generation_count_, and OpenDDS::DCPS::ReceivedDataElement::no_writers_generation_count_.

00035 {
00036   return item->disposed_generation_count_ == disposed_generation_count_
00037          && item->no_writers_generation_count_ == no_writers_generation_count_;
00038 }

ACE_INLINE bool OpenDDS::DCPS::InstanceState::no_writer (  )  const

Definition at line 163 of file InstanceState.inl.

References writers_.

00164 {
00165   ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex,
00166                    guard, this->lock_, true);
00167 
00168   return this->writers_.size () == 0;
00169 }

ACE_INLINE size_t OpenDDS::DCPS::InstanceState::no_writers_generation_count (  )  const

Access no writers generation count.

Definition at line 61 of file InstanceState.inl.

References no_writers_generation_count_.

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

00062 {
00063   return no_writers_generation_count_ ;
00064 }

void OpenDDS::DCPS::InstanceState::registered ( bool  flag  ) 

Definition at line 287 of file InstanceState.cpp.

References registered_.

00288 {
00289   this->registered_ = flag;
00290 }

bool OpenDDS::DCPS::InstanceState::registered (  ) 

Definition at line 279 of file InstanceState.cpp.

References registered_.

Referenced by OpenDDS::DCPS::OwnershipManager::select_owner().

00280 {
00281   bool ret = this->registered_;
00282   this->registered_ = true;
00283   return ret;
00284 }

void OpenDDS::DCPS::InstanceState::release (  ) 

Remove the instance immediately.

Definition at line 255 of file InstanceState.cpp.

References reader_, and OpenDDS::DCPS::DataReaderImpl::release_instance().

Referenced by handle_timeout(), and release_if_empty().

00256 {
00257   this->reader_->release_instance(this->handle_);
00258 }

bool OpenDDS::DCPS::InstanceState::release_if_empty (  ) 

Remove the instance if it's instance has no samples and no writers. Returns true if the instance was released.

Definition at line 242 of file InstanceState.cpp.

References release(), and schedule_pending().

Referenced by empty().

00243 {
00244   bool released = false;
00245   if (this->empty_ && this->writers_.empty()) {
00246     release();
00247     released = true;
00248   } else {
00249     schedule_pending();
00250   }
00251   return released;
00252 }

void OpenDDS::DCPS::InstanceState::reset_ownership ( ::DDS::InstanceHandle_t  instance  ) 

Definition at line 293 of file InstanceState.cpp.

References OpenDDS::DCPS::GUID_UNKNOWN, owner_, reader_, registered_, and OpenDDS::DCPS::DataReaderImpl::reset_ownership().

00294 {
00295   this->owner_ = GUID_UNKNOWN;
00296   this->registered_ = false;
00297 
00298   this->reader_->reset_ownership(instance);
00299 }

void OpenDDS::DCPS::InstanceState::sample_info ( DDS::SampleInfo si,
const ReceivedDataElement de 
)

Populate the SampleInfo structure.

Definition at line 53 of file InstanceState.cpp.

References DDS::SampleInfo::absolute_generation_rank, DDS::SampleInfo::disposed_generation_count, OpenDDS::DCPS::ReceivedDataElement::disposed_generation_count_, disposed_generation_count_, DDS::SampleInfo::generation_rank, OpenDDS::DCPS::SequenceNumber::getValue(), handle_, OpenDDS::DCPS::DomainParticipantImpl::id_to_handle(), DDS::SampleInfo::instance_handle, DDS::SampleInfo::instance_state, instance_state_, DDS::SampleInfo::no_writers_generation_count, OpenDDS::DCPS::ReceivedDataElement::no_writers_generation_count_, no_writers_generation_count_, DDS::SampleInfo::opendds_reserved_publication_seq, OpenDDS::DCPS::DataReaderImpl::participant_servant_, OpenDDS::DCPS::ReceivedDataElement::pub_, DDS::SampleInfo::publication_handle, reader_, OpenDDS::DCPS::ReceivedDataElement::registered_data_, DDS::SampleInfo::sample_rank, DDS::SampleInfo::sample_state, OpenDDS::DCPS::ReceivedDataElement::sample_state_, OpenDDS::DCPS::ReceivedDataElement::sequence_, DDS::SampleInfo::source_timestamp, OpenDDS::DCPS::ReceivedDataElement::source_timestamp_, DDS::SampleInfo::valid_data, DDS::SampleInfo::view_state, and view_state_.

Referenced by OpenDDS::DCPS::RakeResults< SampleSeq >::copy_into().

00055 {
00056   si.sample_state = de->sample_state_;
00057   si.view_state = view_state_;
00058   si.instance_state = instance_state_;
00059   si.disposed_generation_count =
00060     static_cast<CORBA::Long>(disposed_generation_count_);
00061   si.no_writers_generation_count =
00062     static_cast<CORBA::Long>(no_writers_generation_count_);
00063   si.source_timestamp = de->source_timestamp_;
00064   si.instance_handle = handle_;
00065   si.publication_handle = this->reader_->participant_servant_->id_to_handle(de->pub_);
00066   si.valid_data = de->registered_data_ != 0;
00067   /*
00068    * These are actually calculated later...
00069    */
00070   si.sample_rank = 0;
00071 
00072   // these aren't the real value, they're being saved
00073   // for a later calculation. the actual value is
00074   // calculated in DataReaderImpl::sample_info using
00075   // these values.
00076   si.generation_rank =
00077     static_cast<CORBA::Long>(de->disposed_generation_count_ +
00078                              de->no_writers_generation_count_);
00079   si.absolute_generation_rank =
00080     static_cast<CORBA::Long>(de->disposed_generation_count_ +
00081                              de->no_writers_generation_count_);
00082 
00083   si.opendds_reserved_publication_seq = de->sequence_.getValue();
00084 }

void OpenDDS::DCPS::InstanceState::schedule_pending (  ) 

Schedule a pending release of resources.

Definition at line 174 of file InstanceState.cpp.

References release_pending_.

Referenced by release_if_empty(), and schedule_release().

00175 {
00176   this->release_pending_ = true;
00177 }

void OpenDDS::DCPS::InstanceState::schedule_release (  ) 

Schedule an immediate release of resources.

Definition at line 180 of file InstanceState.cpp.

References cancel_release(), DDS::DURATION_INFINITE_NSEC, DDS::DURATION_INFINITE_SEC, OpenDDS::DCPS::duration_to_time_value(), OpenDDS::DCPS::DataReaderImpl::get_qos(), OpenDDS::DCPS::DataReaderImpl::get_reactor(), DDS::Duration_t::nanosec, DDS::NOT_ALIVE_DISPOSED_INSTANCE_STATE, DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE, reader_, DDS::DataReaderQos::reader_data_lifecycle, release_timer_id_, schedule_pending(), and DDS::Duration_t::sec.

Referenced by dispose_was_received(), unregister_was_received(), and writer_became_dead().

00181 {
00182   DDS::DataReaderQos qos;
00183   this->reader_->get_qos(qos);
00184 
00185   DDS::Duration_t delay;
00186 
00187   switch (this->instance_state_) {
00188   case DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE:
00189     delay = qos.reader_data_lifecycle.autopurge_nowriter_samples_delay;
00190     break;
00191 
00192   case DDS::NOT_ALIVE_DISPOSED_INSTANCE_STATE:
00193     delay = qos.reader_data_lifecycle.autopurge_disposed_samples_delay;
00194     break;
00195 
00196   default:
00197     ACE_ERROR((LM_ERROR,
00198                ACE_TEXT("(%P|%t) ERROR: InstanceState::schedule_release:")
00199                ACE_TEXT(" Unsupported instance state: %d!\n"),
00200                this->instance_state_));
00201     return;
00202   }
00203 
00204   if (delay.sec != DDS::DURATION_INFINITE_SEC &&
00205       delay.nanosec != DDS::DURATION_INFINITE_NSEC) {
00206     cancel_release();
00207 
00208     ACE_Reactor_Timer_Interface* reactor = this->reader_->get_reactor();
00209 
00210     this->release_timer_id_ =
00211       reactor->schedule_timer(this, 0, duration_to_time_value(delay));
00212 
00213     if (this->release_timer_id_ == -1) {
00214       ACE_ERROR((LM_ERROR,
00215                  ACE_TEXT("(%P|%t) ERROR: InstanceState::schedule_release:")
00216                  ACE_TEXT(" Unable to schedule timer!\n")));
00217     }
00218 
00219   } else {
00220     // N.B. instance transitions are always followed by a non-valid
00221     // sample being queued to the ReceivedDataElementList; marking
00222     // the release as pending prevents this sample from being lost
00223     // if all samples have been already removed from the instance.
00224     schedule_pending();
00225   }
00226 }

void OpenDDS::DCPS::InstanceState::set_owner ( const PublicationId owner  ) 

Definition at line 261 of file InstanceState.cpp.

References owner_.

00262 {
00263   this->owner_ = owner;
00264 }

bool OpenDDS::DCPS::InstanceState::unregister_was_received ( const PublicationId writer_id  ) 

UNREGISTER message received for this instance. Return flag indicates whether the instance state was changed. This flag is used by concreate DataReader to determine whether it should notify listener. If state is not changed, the unregister message is ignored.

Definition at line 134 of file InstanceState.cpp.

References DDS::ALIVE_INSTANCE_STATE, instance_state_, DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE, schedule_release(), and writers_.

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

00135 {
00136   ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex,
00137                    guard, this->lock_, false);
00138   writers_.erase(writer_id);
00139 #ifndef OPENDDS_NO_OWNERSHIP_KIND_EXCLUSIVE
00140   if (this->exclusive_) {
00141     // If unregistered by owner then the ownership should be transferred to another
00142     // writer.
00143     (void) this->reader_->owner_manager_->remove_writer (
00144              this->handle_, writer_id);
00145   }
00146 #endif
00147 
00148   if (writers_.empty() && (this->instance_state_ & DDS::ALIVE_INSTANCE_STATE)) {
00149     this->instance_state_ = DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE;
00150     schedule_release();
00151     return true;
00152   }
00153 
00154   return false;
00155 }

ACE_INLINE DDS::ViewStateKind OpenDDS::DCPS::InstanceState::view_state (  )  const

Access view state.

Definition at line 49 of file InstanceState.inl.

References view_state_.

Referenced by OpenDDS::DCPS::DataReaderImpl_T< MessageType >::read_instance_i(), and OpenDDS::DCPS::DataReaderImpl_T< MessageType >::take_instance_i().

00050 {
00051   return this->view_state_ ;
00052 }

void OpenDDS::DCPS::InstanceState::writer_became_dead ( const PublicationId writer_id,
int  num_alive_writers,
const ACE_Time_Value &  when 
)

tell this instance when a DataWriter transitions to NOT_ALIVE

Definition at line 158 of file InstanceState.cpp.

References DDS::ALIVE_INSTANCE_STATE, instance_state_, DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE, schedule_release(), and writers_.

00162 {
00163   ACE_GUARD(ACE_Recursive_Thread_Mutex,
00164             guard, this->lock_);
00165   writers_.erase(writer_id);
00166 
00167   if (writers_.empty() && this->instance_state_ & DDS::ALIVE_INSTANCE_STATE) {
00168     this->instance_state_ = DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE;
00169     schedule_release();
00170   }
00171 }


Member Data Documentation

size_t OpenDDS::DCPS::InstanceState::disposed_generation_count_ [private]

Number of times the instance state changes from NOT_ALIVE_DISPOSED to ALIVE.

Definition at line 168 of file InstanceState.h.

Referenced by data_was_received(), disposed_generation_count(), most_recent_generation(), and sample_info().

bool OpenDDS::DCPS::InstanceState::empty_ [private]

Keep track of whether the DataReader is empty or not.

Definition at line 177 of file InstanceState.h.

bool OpenDDS::DCPS::InstanceState::exclusive_ [private]

Definition at line 200 of file InstanceState.h.

Referenced by is_exclusive().

DDS::InstanceHandle_t OpenDDS::DCPS::InstanceState::handle_ [private]

Definition at line 196 of file InstanceState.h.

Referenced by sample_info().

DDS::InstanceStateKind OpenDDS::DCPS::InstanceState::instance_state_ [private]

Current instance state.

Can have values defined as:

DDS::ALIVE_INSTANCE_STATE DDS::NOT_ALIVE_DISPOSED_INSTANCE_STATE DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE

and can be checked with the masks:

DDS::ANY_INSTANCE_STATE DDS::NOT_ALIVE_INSTANCE_STATE

Definition at line 150 of file InstanceState.h.

Referenced by data_was_received(), instance_state(), lively(), sample_info(), unregister_was_received(), and writer_became_dead().

ACE_Recursive_Thread_Mutex& OpenDDS::DCPS::InstanceState::lock_ [private]

Definition at line 134 of file InstanceState.h.

size_t OpenDDS::DCPS::InstanceState::no_writers_generation_count_ [private]

Number of times the instance state changes from NOT_ALIVE_NO_WRITERS to ALIVE.

Definition at line 172 of file InstanceState.h.

Referenced by data_was_received(), lively(), most_recent_generation(), no_writers_generation_count(), and sample_info().

PublicationId OpenDDS::DCPS::InstanceState::owner_ [private]

Definition at line 199 of file InstanceState.h.

Referenced by get_owner(), reset_ownership(), and set_owner().

DataReaderImpl* OpenDDS::DCPS::InstanceState::reader_ [private]

Reference to our containing reader. This is used to call back and notify the reader that liveliness has been lost on this instance. It is also queried to determine if the DataReader is empty -- that it contains no more sample data.

Definition at line 195 of file InstanceState.h.

Referenced by cancel_release(), data_reader(), release(), reset_ownership(), sample_info(), schedule_release(), and ~InstanceState().

bool OpenDDS::DCPS::InstanceState::registered_ [private]

registered with participant so it can be calledback as the owner is updated.

Definition at line 203 of file InstanceState.h.

Referenced by registered(), reset_ownership(), and ~InstanceState().

bool OpenDDS::DCPS::InstanceState::release_pending_ [private]

Keep track of whether the instance is waiting to be released.

Definition at line 182 of file InstanceState.h.

Referenced by cancel_release(), and schedule_pending().

long OpenDDS::DCPS::InstanceState::release_timer_id_ [private]

Keep track of a scheduled release timer.

Definition at line 187 of file InstanceState.h.

Referenced by cancel_release(), and schedule_release().

DDS::ViewStateKind OpenDDS::DCPS::InstanceState::view_state_ [private]

Current instance view state.

Can have values defined as:

DDS::NEW_VIEW_STATE DDS::NOT_NEW_VIEW_STATE

and can be checked with the mask:

DDS::ANY_VIEW_STATE

Definition at line 164 of file InstanceState.h.

Referenced by accessed(), data_was_received(), sample_info(), and view_state().

RepoIdSet OpenDDS::DCPS::InstanceState::writers_ [private]

Definition at line 198 of file InstanceState.h.

Referenced by data_was_received(), dispose_was_received(), lively(), no_writer(), unregister_was_received(), and writer_became_dead().


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