InstanceState.inl
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "ReceivedDataElementList.h"
00009 #include "ace/OS_NS_sys_time.h"
00010
00011 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00012
00013 ACE_INLINE
00014 OpenDDS::DCPS::DataReaderImpl*
00015 OpenDDS::DCPS::InstanceState::data_reader() const
00016 {
00017 return reader_;
00018 }
00019
00020 ACE_INLINE
00021 void
00022 OpenDDS::DCPS::InstanceState::accessed()
00023 {
00024 ACE_GUARD(ACE_Recursive_Thread_Mutex,
00025 guard, this->lock_);
00026
00027
00028
00029 if (this->view_state_ & DDS::ANY_VIEW_STATE) {
00030 this->view_state_ = DDS::NOT_NEW_VIEW_STATE ;
00031 }
00032 }
00033
00034 ACE_INLINE
00035 bool
00036 OpenDDS::DCPS::InstanceState::most_recent_generation(ReceivedDataElement* item) const
00037 {
00038 return item->disposed_generation_count_ == disposed_generation_count_
00039 && item->no_writers_generation_count_ == no_writers_generation_count_;
00040 }
00041
00042 ACE_INLINE
00043 DDS::InstanceStateKind
00044 OpenDDS::DCPS::InstanceState::instance_state() const
00045 {
00046 return this->instance_state_ ;
00047 }
00048
00049 ACE_INLINE
00050 DDS::ViewStateKind
00051 OpenDDS::DCPS::InstanceState::view_state() const
00052 {
00053 return this->view_state_ ;
00054 }
00055
00056 ACE_INLINE
00057 size_t OpenDDS::DCPS::InstanceState::disposed_generation_count() const
00058 {
00059 return disposed_generation_count_ ;
00060 }
00061
00062 ACE_INLINE
00063 size_t OpenDDS::DCPS::InstanceState::no_writers_generation_count() const
00064 {
00065 return no_writers_generation_count_ ;
00066 }
00067
00068 ACE_INLINE
00069 void
00070 OpenDDS::DCPS::InstanceState::data_was_received(const PublicationId& writer_id)
00071 {
00072 ACE_GUARD(ACE_Recursive_Thread_Mutex,
00073 guard, this->lock_);
00074 cancel_release();
00075
00076
00077
00078
00079
00080
00081 writers_.insert(writer_id);
00082
00083 switch (this->view_state_) {
00084 case DDS::NEW_VIEW_STATE:
00085 break ;
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 }
00115
00116 ACE_INLINE
00117 void
00118 OpenDDS::DCPS::InstanceState::lively(const PublicationId& writer_id)
00119 {
00120 ACE_GUARD(ACE_Recursive_Thread_Mutex,
00121 guard, this->lock_);
00122
00123
00124
00125
00126
00127 writers_.insert(writer_id);
00128
00129 if (this->instance_state_ == DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE) {
00130 cancel_release();
00131
00132 this->no_writers_generation_count_++ ;
00133 this->instance_state_ = DDS::ALIVE_INSTANCE_STATE ;
00134 }
00135 }
00136
00137 ACE_INLINE
00138 bool
00139 OpenDDS::DCPS::InstanceState::empty(bool value)
00140 {
00141
00142
00143
00144
00145 if ((this->empty_ = value) && this->release_pending_) {
00146 return release_if_empty();
00147 } else {
00148 return false;
00149 }
00150 }
00151
00152
00153 ACE_INLINE
00154 bool
00155 OpenDDS::DCPS::InstanceState::is_last (const PublicationId& pub)
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 }
00162
00163 ACE_INLINE
00164 bool
00165 OpenDDS::DCPS::InstanceState::no_writer () const
00166 {
00167 ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex,
00168 guard, this->lock_, true);
00169
00170 return this->writers_.size () == 0;
00171 }
00172
00173 OPENDDS_END_VERSIONED_NAMESPACE_DECL