manage the states of a received data instance. More...
#include <InstanceState.h>
Public Member Functions | |
InstanceState (DataReaderImpl *reader, ACE_Recursive_Thread_Mutex &lock, DDS::InstanceHandle_t handle) | |
virtual | ~InstanceState () |
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 | |
DataReaderImpl * | data_reader () const |
virtual int | handle_timeout (const ACE_Time_Value ¤t_time, const void *arg) |
void | set_owner (const PublicationId &owner) |
PublicationId & | get_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 |
OPENDDS_STRING | instance_state_string () const |
Return string of the name of the current instance state. | |
Static Public Member Functions | |
static OPENDDS_STRING | instance_state_string (DDS::InstanceStateKind value) |
Return string of the name of the instance state kind or mask passed. | |
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_ |
DataReaderImpl * | reader_ |
DDS::InstanceHandle_t | handle_ |
RepoIdSet | writers_ |
PublicationId | owner_ |
bool | exclusive_ |
bool | registered_ |
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 42 of file InstanceState.h.
OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL OpenDDS::DCPS::InstanceState::InstanceState | ( | DataReaderImpl * | reader, | |
ACE_Recursive_Thread_Mutex & | lock, | |||
DDS::InstanceHandle_t | handle | |||
) |
Definition at line 25 of file InstanceState.cpp.
00028 : lock_(lock), 00029 instance_state_(0), 00030 view_state_(0), 00031 disposed_generation_count_(0), 00032 no_writers_generation_count_(0), 00033 empty_(true), 00034 release_pending_(false), 00035 release_timer_id_(-1), 00036 reader_(reader), 00037 handle_(handle), 00038 owner_(GUID_UNKNOWN), 00039 #ifndef OPENDDS_NO_OWNERSHIP_KIND_EXCLUSIVE 00040 exclusive_(reader->qos_.ownership.kind == ::DDS::EXCLUSIVE_OWNERSHIP_QOS), 00041 #endif 00042 registered_ (false) 00043 {}
OpenDDS::DCPS::InstanceState::~InstanceState | ( | ) | [virtual] |
Definition at line 45 of file InstanceState.cpp.
References cancel_release(), OpenDDS::DCPS::DataReaderImpl::ownership_manager(), reader_, and registered_.
00046 { 00047 cancel_release(); 00048 #ifndef OPENDDS_NO_OWNERSHIP_KIND_EXCLUSIVE 00049 if (registered_) { 00050 DataReaderImpl::OwnershipManagerPtr om = reader_->ownership_manager(); 00051 if (om) om->remove_instance(this); 00052 } 00053 #endif 00054 }
ACE_INLINE void OpenDDS::DCPS::InstanceState::accessed | ( | ) |
A read or take operation has been performed on this instance.
Definition at line 22 of file InstanceState.inl.
References DDS::ANY_VIEW_STATE, lock_, DDS::NOT_NEW_VIEW_STATE, and view_state_.
Referenced by OpenDDS::DCPS::RakeResults< SampleSeq >::copy_into().
00023 { 00024 ACE_GUARD(ACE_Recursive_Thread_Mutex, 00025 guard, this->lock_); 00026 // 00027 // Manage the view state due to data access here. 00028 // 00029 if (this->view_state_ & DDS::ANY_VIEW_STATE) { 00030 this->view_state_ = DDS::NOT_NEW_VIEW_STATE ; 00031 } 00032 }
void OpenDDS::DCPS::InstanceState::cancel_release | ( | ) |
Cancel a scheduled or pending release of resources.
Definition at line 255 of file InstanceState.cpp.
References ACE_Reactor_Timer_Interface::cancel_timer(), OpenDDS::DCPS::DataReaderImpl::get_reactor(), ACE_Event_Handler::reactor(), reader_, release_pending_, and release_timer_id_.
Referenced by data_was_received(), lively(), schedule_release(), and ~InstanceState().
00256 { 00257 this->release_pending_ = false; 00258 00259 if (this->release_timer_id_ != -1) { 00260 ACE_Reactor_Timer_Interface* reactor = this->reader_->get_reactor(); 00261 reactor->cancel_timer(this->release_timer_id_); 00262 00263 this->release_timer_id_ = -1; 00264 } 00265 }
OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE OpenDDS::DCPS::DataReaderImpl * OpenDDS::DCPS::InstanceState::data_reader | ( | ) | const |
Definition at line 15 of file InstanceState.inl.
References reader_.
00016 { 00017 return reader_; 00018 }
ACE_INLINE void OpenDDS::DCPS::InstanceState::data_was_received | ( | const PublicationId & | writer_id | ) |
Data sample received for this instance.
Definition at line 70 of file InstanceState.inl.
References DDS::ALIVE_INSTANCE_STATE, cancel_release(), disposed_generation_count_, instance_state_, lock_, 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_.
00071 { 00072 ACE_GUARD(ACE_Recursive_Thread_Mutex, 00073 guard, this->lock_); 00074 cancel_release(); 00075 00076 // 00077 // Update the view state here, since only sample data received affects 00078 // this state value. Then manage the data sample only transitions 00079 // here. Let the lively() method manage the other transitions. 00080 // 00081 writers_.insert(writer_id); 00082 00083 switch (this->view_state_) { 00084 case DDS::NEW_VIEW_STATE: 00085 break ; // No action. 00086 00087 case DDS::NOT_NEW_VIEW_STATE: 00088 00089 if (this->instance_state_ & DDS::NOT_ALIVE_INSTANCE_STATE) { 00090 this->view_state_ = DDS::NEW_VIEW_STATE ; 00091 } 00092 00093 break ; 00094 00095 default: 00096 this->view_state_ = DDS::NEW_VIEW_STATE ; 00097 break ; 00098 } 00099 00100 switch (this->instance_state_) { 00101 case DDS::NOT_ALIVE_DISPOSED_INSTANCE_STATE: 00102 ++this->disposed_generation_count_; 00103 break ; 00104 00105 case DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE: 00106 ++this->no_writers_generation_count_; 00107 break ; 00108 00109 default: 00110 break ; 00111 } 00112 00113 this->instance_state_ = DDS::ALIVE_INSTANCE_STATE ; 00114 }
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 concrete DataReader to determine whether it should notify listener. If state is not changed, the dispose message is ignored.
Definition at line 109 of file InstanceState.cpp.
References DDS::ALIVE_INSTANCE_STATE, exclusive_, instance_state_, lock_, DDS::NOT_ALIVE_DISPOSED_INSTANCE_STATE, OpenDDS::DCPS::DataReaderImpl::ownership_manager(), reader_, schedule_release(), and writers_.
00110 { 00111 ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, 00112 guard, this->lock_, false); 00113 00114 writers_.erase(writer_id); 00115 00116 // 00117 // Manage the instance state on disposal here. 00118 // 00119 // If disposed by owner then the owner is not re-elected, it can 00120 // resume if the writer sends message again. 00121 if (this->instance_state_ & DDS::ALIVE_INSTANCE_STATE) { 00122 #ifndef OPENDDS_NO_OWNERSHIP_KIND_EXCLUSIVE 00123 DataReaderImpl::OwnershipManagerPtr owner_manager = this->reader_->ownership_manager(); 00124 if (! this->exclusive_ 00125 || (owner_manager && owner_manager->is_owner (this->handle_, writer_id))) { 00126 #endif 00127 this->instance_state_ = DDS::NOT_ALIVE_DISPOSED_INSTANCE_STATE; 00128 schedule_release(); 00129 return true; 00130 #ifndef OPENDDS_NO_OWNERSHIP_KIND_EXCLUSIVE 00131 } 00132 #endif 00133 } 00134 00135 return false; 00136 }
ACE_INLINE size_t OpenDDS::DCPS::InstanceState::disposed_generation_count | ( | ) | const |
Access disposed generation count.
Definition at line 57 of file InstanceState.inl.
References disposed_generation_count_.
00058 { 00059 return disposed_generation_count_ ; 00060 }
ACE_INLINE bool OpenDDS::DCPS::InstanceState::empty | ( | bool | value | ) |
DataReader has become empty. Returns true if the instance was released.
Definition at line 139 of file InstanceState.inl.
References empty_, release_if_empty(), and release_pending_.
Referenced by OpenDDS::DCPS::ReceivedDataElementList::add(), and OpenDDS::DCPS::ReceivedDataElementList::remove().
00140 { 00141 // 00142 // Manage the instance state due to the DataReader becoming empty 00143 // here. 00144 // 00145 if ((this->empty_ = value) && this->release_pending_) { 00146 return release_if_empty(); 00147 } else { 00148 return false; 00149 } 00150 }
OpenDDS::DCPS::PublicationId & OpenDDS::DCPS::InstanceState::get_owner | ( | ) |
Definition at line 293 of file InstanceState.cpp.
References owner_.
00294 { 00295 return this->owner_; 00296 }
int OpenDDS::DCPS::InstanceState::handle_timeout | ( | const ACE_Time_Value & | current_time, | |
const void * | arg | |||
) | [virtual] |
Reimplemented from ACE_Event_Handler.
Definition at line 93 of file InstanceState.cpp.
References ACE_TEXT(), OpenDDS::DCPS::DCPS_debug_level, handle_, LM_NOTICE, and release().
00095 { 00096 if (OpenDDS::DCPS::DCPS_debug_level > 0) { 00097 ACE_DEBUG((LM_NOTICE, 00098 ACE_TEXT("(%P|%t) NOTICE:") 00099 ACE_TEXT(" InstanceState::handle_timeout:") 00100 ACE_TEXT(" autopurging samples with instance handle 0x%x!\n"), 00101 this->handle_)); 00102 } 00103 this->release(); 00104 00105 return 0; 00106 }
DDS::InstanceHandle_t OpenDDS::DCPS::InstanceState::instance_handle | ( | ) | const [inline] |
Definition at line 132 of file InstanceState.h.
Referenced by OpenDDS::DCPS::OwnershipManager::remove_instance().
00132 { return handle_; }
ACE_INLINE DDS::InstanceStateKind OpenDDS::DCPS::InstanceState::instance_state | ( | ) | const |
Access instance state.
Definition at line 44 of file InstanceState.inl.
References instance_state_.
Referenced by OpenDDS::DCPS::DataReaderImpl::contains_sample(), OpenDDS::DCPS::DataReaderImpl_T< MessageType >::contains_sample_filtered(), and OpenDDS::DCPS::DataReaderImpl_T< MessageType >::read_instance_i().
00045 { 00046 return this->instance_state_ ; 00047 }
OPENDDS_STRING OpenDDS::DCPS::InstanceState::instance_state_string | ( | DDS::InstanceStateKind | value | ) | [static] |
Return string of the name of the instance state kind or mask passed.
Definition at line 328 of file InstanceState.cpp.
References ACE_TEXT(), DDS::ALIVE_INSTANCE_STATE, DDS::ANY_INSTANCE_STATE, LM_ERROR, DDS::NOT_ALIVE_DISPOSED_INSTANCE_STATE, DDS::NOT_ALIVE_INSTANCE_STATE, DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE, OPENDDS_STRING, and OpenDDS::DCPS::to_dds_string().
00329 { 00330 switch (value) { 00331 case DDS::ALIVE_INSTANCE_STATE: 00332 return OPENDDS_STRING("ALIVE_INSTANCE_STATE"); 00333 case DDS::NOT_ALIVE_INSTANCE_STATE: 00334 return OPENDDS_STRING("NOT_ALIVE_INSTANCE_STATE"); 00335 case DDS::NOT_ALIVE_DISPOSED_INSTANCE_STATE: 00336 return OPENDDS_STRING("NOT_ALIVE_DISPOSED_INSTANCE_STATE"); 00337 case DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE: 00338 return OPENDDS_STRING("NOT_ALIVE_NO_WRITERS_INSTANCE_STATE"); 00339 case DDS::ANY_INSTANCE_STATE: 00340 return OPENDDS_STRING("ANY_INSTANCE_STATE"); 00341 default: 00342 ACE_ERROR((LM_ERROR, 00343 ACE_TEXT( 00344 "(%P|%t) ERROR: OpenDDS::DCPS::InstanceState::instance_state_string(): " 00345 "%d is either completely invalid or at least not defined in this function.\n" 00346 ), 00347 value 00348 )); 00349 00350 return OPENDDS_STRING("(Unknown Instance State: ") + to_dds_string(value) + ")"; 00351 } 00352 }
OPENDDS_STRING OpenDDS::DCPS::InstanceState::instance_state_string | ( | ) | const [inline] |
Return string of the name of the current instance state.
Definition at line 135 of file InstanceState.h.
Referenced by OpenDDS::DCPS::DataReaderImpl_T< MessageType >::read_instance_i().
00136 { 00137 return instance_state_string(instance_state_); 00138 }
bool OpenDDS::DCPS::InstanceState::is_exclusive | ( | ) | const |
Definition at line 299 of file InstanceState.cpp.
References exclusive_.
00300 { 00301 return this->exclusive_; 00302 }
ACE_INLINE bool OpenDDS::DCPS::InstanceState::is_last | ( | const PublicationId & | pub | ) |
Definition at line 155 of file InstanceState.inl.
References lock_, and writers_.
00156 { 00157 ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, 00158 guard, this->lock_, false); 00159 00160 return (this->writers_.size () == 1) && *(this->writers_.begin ()) == pub; 00161 }
ACE_INLINE void OpenDDS::DCPS::InstanceState::lively | ( | const PublicationId & | writer_id | ) |
LIVELINESS message received for this DataWriter.
Definition at line 118 of file InstanceState.inl.
References DDS::ALIVE_INSTANCE_STATE, cancel_release(), instance_state_, lock_, no_writers_generation_count_, DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE, and writers_.
00119 { 00120 ACE_GUARD(ACE_Recursive_Thread_Mutex, 00121 guard, this->lock_); 00122 00123 // 00124 // Manage transisitions in the instance state that do not require a 00125 // data sample, but merely the notion of liveliness. 00126 // 00127 writers_.insert(writer_id); 00128 00129 if (this->instance_state_ == DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE) { 00130 cancel_release(); // cancel unregister 00131 00132 this->no_writers_generation_count_++ ; 00133 this->instance_state_ = DDS::ALIVE_INSTANCE_STATE ; 00134 } 00135 }
ACE_INLINE bool OpenDDS::DCPS::InstanceState::most_recent_generation | ( | ReceivedDataElement * | item | ) | const |
Definition at line 36 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_.
Referenced by OpenDDS::DCPS::RakeResults< SampleSeq >::copy_into().
00037 { 00038 return item->disposed_generation_count_ == disposed_generation_count_ 00039 && item->no_writers_generation_count_ == no_writers_generation_count_; 00040 }
ACE_INLINE bool OpenDDS::DCPS::InstanceState::no_writer | ( | ) | const |
Definition at line 165 of file InstanceState.inl.
References lock_, and writers_.
00166 { 00167 ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, 00168 guard, this->lock_, true); 00169 00170 return this->writers_.size () == 0; 00171 }
ACE_INLINE size_t OpenDDS::DCPS::InstanceState::no_writers_generation_count | ( | ) | const |
Access no writers generation count.
Definition at line 63 of file InstanceState.inl.
References no_writers_generation_count_.
00064 { 00065 return no_writers_generation_count_ ; 00066 }
void OpenDDS::DCPS::InstanceState::registered | ( | bool | flag | ) |
Definition at line 313 of file InstanceState.cpp.
References registered_.
00314 { 00315 this->registered_ = flag; 00316 }
bool OpenDDS::DCPS::InstanceState::registered | ( | ) |
Definition at line 305 of file InstanceState.cpp.
References registered_.
Referenced by OpenDDS::DCPS::OwnershipManager::select_owner().
00306 { 00307 bool ret = this->registered_; 00308 this->registered_ = true; 00309 return ret; 00310 }
void OpenDDS::DCPS::InstanceState::release | ( | void | ) |
Remove the instance immediately.
Definition at line 281 of file InstanceState.cpp.
References handle_, reader_, and OpenDDS::DCPS::DataReaderImpl::release_instance().
Referenced by handle_timeout(), and release_if_empty().
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 268 of file InstanceState.cpp.
References empty_, release(), schedule_pending(), and writers_.
Referenced by empty().
00269 { 00270 bool released = false; 00271 if (this->empty_ && this->writers_.empty()) { 00272 release(); 00273 released = true; 00274 } else { 00275 schedule_pending(); 00276 } 00277 return released; 00278 }
void OpenDDS::DCPS::InstanceState::reset_ownership | ( | DDS::InstanceHandle_t | instance | ) |
void OpenDDS::DCPS::InstanceState::sample_info | ( | DDS::SampleInfo & | si, | |
const ReceivedDataElement * | de | |||
) |
Populate the SampleInfo structure.
Definition at line 56 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_, DDS::SampleInfo::instance_handle, DDS::SampleInfo::instance_state, instance_state_, OpenDDS::DCPS::WeakRcHandle< T >::lock(), 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().
00058 { 00059 si.sample_state = de->sample_state_; 00060 si.view_state = view_state_; 00061 si.instance_state = instance_state_; 00062 si.disposed_generation_count = 00063 static_cast<CORBA::Long>(disposed_generation_count_); 00064 si.no_writers_generation_count = 00065 static_cast<CORBA::Long>(no_writers_generation_count_); 00066 si.source_timestamp = de->source_timestamp_; 00067 si.instance_handle = handle_; 00068 RcHandle<DomainParticipantImpl> participant = this->reader_->participant_servant_.lock(); 00069 si.publication_handle = participant ? participant->id_to_handle(de->pub_) : 0; 00070 si.valid_data = de->registered_data_ != 0; 00071 /* 00072 * These are actually calculated later... 00073 */ 00074 si.sample_rank = 0; 00075 00076 // these aren't the real value, they're being saved 00077 // for a later calculation. the actual value is 00078 // calculated in DataReaderImpl::sample_info using 00079 // these values. 00080 si.generation_rank = 00081 static_cast<CORBA::Long>(de->disposed_generation_count_ + 00082 de->no_writers_generation_count_); 00083 si.absolute_generation_rank = 00084 static_cast<CORBA::Long>(de->disposed_generation_count_ + 00085 de->no_writers_generation_count_); 00086 00087 si.opendds_reserved_publication_seq = de->sequence_.getValue(); 00088 }
void OpenDDS::DCPS::InstanceState::schedule_pending | ( | ) |
Schedule a pending release of resources.
Definition at line 200 of file InstanceState.cpp.
References release_pending_.
Referenced by release_if_empty(), and schedule_release().
00201 { 00202 this->release_pending_ = true; 00203 }
void OpenDDS::DCPS::InstanceState::schedule_release | ( | ) |
Schedule an immediate release of resources.
Definition at line 206 of file InstanceState.cpp.
References ACE_TEXT(), 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(), instance_state_, LM_ERROR, DDS::Duration_t::nanosec, DDS::NOT_ALIVE_DISPOSED_INSTANCE_STATE, DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE, ACE_Event_Handler::reactor(), reader_, DDS::DataReaderQos::reader_data_lifecycle, release_timer_id_, schedule_pending(), ACE_Reactor_Timer_Interface::schedule_timer(), and DDS::Duration_t::sec.
Referenced by dispose_was_received(), unregister_was_received(), and writer_became_dead().
00207 { 00208 DDS::DataReaderQos qos; 00209 this->reader_->get_qos(qos); 00210 00211 DDS::Duration_t delay; 00212 00213 switch (this->instance_state_) { 00214 case DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE: 00215 delay = qos.reader_data_lifecycle.autopurge_nowriter_samples_delay; 00216 break; 00217 00218 case DDS::NOT_ALIVE_DISPOSED_INSTANCE_STATE: 00219 delay = qos.reader_data_lifecycle.autopurge_disposed_samples_delay; 00220 break; 00221 00222 default: 00223 ACE_ERROR((LM_ERROR, 00224 ACE_TEXT("(%P|%t) ERROR: InstanceState::schedule_release:") 00225 ACE_TEXT(" Unsupported instance state: %d!\n"), 00226 this->instance_state_)); 00227 return; 00228 } 00229 00230 if (delay.sec != DDS::DURATION_INFINITE_SEC && 00231 delay.nanosec != DDS::DURATION_INFINITE_NSEC) { 00232 cancel_release(); 00233 00234 ACE_Reactor_Timer_Interface* reactor = this->reader_->get_reactor(); 00235 00236 this->release_timer_id_ = 00237 reactor->schedule_timer(this, 0, duration_to_time_value(delay)); 00238 00239 if (this->release_timer_id_ == -1) { 00240 ACE_ERROR((LM_ERROR, 00241 ACE_TEXT("(%P|%t) ERROR: InstanceState::schedule_release:") 00242 ACE_TEXT(" Unable to schedule timer!\n"))); 00243 } 00244 00245 } else { 00246 // N.B. instance transitions are always followed by a non-valid 00247 // sample being queued to the ReceivedDataElementList; marking 00248 // the release as pending prevents this sample from being lost 00249 // if all samples have been already removed from the instance. 00250 schedule_pending(); 00251 } 00252 }
void OpenDDS::DCPS::InstanceState::set_owner | ( | const PublicationId & | owner | ) |
Definition at line 287 of file InstanceState.cpp.
References owner_.
00288 { 00289 this->owner_ = owner; 00290 }
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 concrete DataReader to determine whether it should notify listener. If state is not changed, the unregister message is ignored.
Definition at line 139 of file InstanceState.cpp.
References ACE_TEXT(), DDS::ALIVE_INSTANCE_STATE, OpenDDS::DCPS::DCPS_debug_level, exclusive_, handle_, instance_state_, LM_DEBUG, lock_, DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE, OPENDDS_STRING, OpenDDS::DCPS::DataReaderImpl::ownership_manager(), reader_, schedule_release(), and writers_.
00140 { 00141 if (OpenDDS::DCPS::DCPS_debug_level > 1) { 00142 GuidConverter conv(writer_id); 00143 ACE_DEBUG((LM_DEBUG, 00144 ACE_TEXT( 00145 "(%P|%t) InstanceState::unregister_was_received on %C\n" 00146 ), 00147 OPENDDS_STRING(conv).c_str() 00148 )); 00149 } 00150 00151 ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, 00152 guard, this->lock_, false); 00153 writers_.erase(writer_id); 00154 #ifndef OPENDDS_NO_OWNERSHIP_KIND_EXCLUSIVE 00155 if (this->exclusive_) { 00156 // If unregistered by owner then the ownership should be transferred to another 00157 // writer. 00158 DataReaderImpl::OwnershipManagerPtr owner_manager = this->reader_->ownership_manager(); 00159 if (owner_manager) 00160 owner_manager->remove_writer (this->handle_, writer_id); 00161 } 00162 #endif 00163 00164 if (writers_.empty() && (this->instance_state_ & DDS::ALIVE_INSTANCE_STATE)) { 00165 this->instance_state_ = DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE; 00166 schedule_release(); 00167 return true; 00168 } 00169 00170 return false; 00171 }
ACE_INLINE DDS::ViewStateKind OpenDDS::DCPS::InstanceState::view_state | ( | ) | const |
Access view state.
Definition at line 51 of file InstanceState.inl.
References view_state_.
Referenced by OpenDDS::DCPS::DataReaderImpl::contains_sample(), OpenDDS::DCPS::DataReaderImpl_T< MessageType >::contains_sample_filtered(), and OpenDDS::DCPS::DataReaderImpl_T< MessageType >::read_instance_i().
00052 { 00053 return this->view_state_ ; 00054 }
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 174 of file InstanceState.cpp.
References ACE_TEXT(), DDS::ALIVE_INSTANCE_STATE, OpenDDS::DCPS::DCPS_debug_level, instance_state_, LM_DEBUG, lock_, DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE, OPENDDS_STRING, schedule_release(), and writers_.
00178 { 00179 if (OpenDDS::DCPS::DCPS_debug_level > 1) { 00180 GuidConverter conv(writer_id); 00181 ACE_DEBUG((LM_DEBUG, 00182 ACE_TEXT( 00183 "(%P|%t) InstanceState::writer_became_dead on %C\n" 00184 ), 00185 OPENDDS_STRING(conv).c_str() 00186 )); 00187 } 00188 00189 ACE_GUARD(ACE_Recursive_Thread_Mutex, 00190 guard, this->lock_); 00191 writers_.erase(writer_id); 00192 00193 if (writers_.empty() && this->instance_state_ & DDS::ALIVE_INSTANCE_STATE) { 00194 this->instance_state_ = DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE; 00195 schedule_release(); 00196 } 00197 }
Number of times the instance state changes from NOT_ALIVE_DISPOSED to ALIVE.
Definition at line 178 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 187 of file InstanceState.h.
Referenced by empty(), and release_if_empty().
bool OpenDDS::DCPS::InstanceState::exclusive_ [private] |
Definition at line 210 of file InstanceState.h.
Referenced by dispose_was_received(), is_exclusive(), and unregister_was_received().
Definition at line 206 of file InstanceState.h.
Referenced by handle_timeout(), release(), sample_info(), and unregister_was_received().
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 160 of file InstanceState.h.
Referenced by data_was_received(), dispose_was_received(), instance_state(), lively(), sample_info(), schedule_release(), unregister_was_received(), and writer_became_dead().
Definition at line 144 of file InstanceState.h.
Referenced by accessed(), data_was_received(), dispose_was_received(), is_last(), lively(), no_writer(), unregister_was_received(), and writer_became_dead().
Number of times the instance state changes from NOT_ALIVE_NO_WRITERS to ALIVE.
Definition at line 182 of file InstanceState.h.
Referenced by data_was_received(), lively(), most_recent_generation(), no_writers_generation_count(), and sample_info().
Definition at line 209 of file InstanceState.h.
Referenced by get_owner(), and set_owner().
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 205 of file InstanceState.h.
Referenced by cancel_release(), data_reader(), dispose_was_received(), release(), sample_info(), schedule_release(), unregister_was_received(), and ~InstanceState().
bool OpenDDS::DCPS::InstanceState::registered_ [private] |
registered with participant so it can be called back as the owner is updated.
Definition at line 213 of file InstanceState.h.
Referenced by registered(), and ~InstanceState().
bool OpenDDS::DCPS::InstanceState::release_pending_ [private] |
Keep track of whether the instance is waiting to be released.
Definition at line 192 of file InstanceState.h.
Referenced by cancel_release(), empty(), and schedule_pending().
long OpenDDS::DCPS::InstanceState::release_timer_id_ [private] |
Keep track of a scheduled release timer.
Definition at line 197 of file InstanceState.h.
Referenced by cancel_release(), and schedule_release().
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:
Definition at line 174 of file InstanceState.h.
Referenced by accessed(), data_was_received(), sample_info(), and view_state().
RepoIdSet OpenDDS::DCPS::InstanceState::writers_ [private] |
Definition at line 208 of file InstanceState.h.
Referenced by data_was_received(), dispose_was_received(), is_last(), lively(), no_writer(), release_if_empty(), unregister_was_received(), and writer_became_dead().