| 2130 | } |
| 2131 | |
| 2132 | void DataReaderImpl::process_latency(const ReceivedDataSample& sample) |
| 2133 | { |
| 2134 | ACE_Guard<ACE_Recursive_Thread_Mutex> guard(statistics_lock_); |
| 2135 | StatsMapType::iterator location = this->statistics_.find(sample.header_.publication_id_); |
| 2136 | |
| 2137 | if (location != this->statistics_.end()) { |
| 2138 | const DDS::Duration_t zero = { DDS::DURATION_ZERO_SEC, DDS::DURATION_ZERO_NSEC }; |
| 2139 | |
| 2140 | // Only when the user has specified a latency budget or statistics |
| 2141 | // are enabled we need to calculate our latency |
| 2142 | if ((this->statistics_enabled()) || |
| 2143 | (this->qos_.latency_budget.duration > zero)) { |
| 2144 | const DDS::Time_t timestamp = { |
| 2145 | sample.header_.source_timestamp_sec_, |
| 2146 | sample.header_.source_timestamp_nanosec_ |
| 2147 | }; |
| 2148 | const TimeDuration latency = SystemTimePoint::now() - SystemTimePoint(timestamp); |
| 2149 | |
| 2150 | if (this->statistics_enabled()) { |
| 2151 | location->second.add_stat(latency); |
| 2152 | } |
| 2153 | |
| 2154 | if (DCPS_debug_level > 9) { |
| 2155 | ACE_DEBUG((LM_DEBUG, |
| 2156 | ACE_TEXT("(%P|%t) DataReaderImpl::process_latency() - ") |
| 2157 | ACE_TEXT("measured latency of %C for current sample.\n"), |
| 2158 | latency.str().c_str())); |
| 2159 | } |
| 2160 | |
| 2161 | if (this->qos_.latency_budget.duration > zero) { |
| 2162 | // Check latency against the budget. |
| 2163 | if (latency > TimeDuration(this->qos_.latency_budget.duration)) { |
| 2164 | this->notify_latency(sample.header_.publication_id_); |
| 2165 | } |
| 2166 | } |
| 2167 | } |
| 2168 | } else if (DCPS_debug_level > 0) { |
| 2169 | /// NB: This message is generated contemporaneously with a similar |
| 2170 | /// message from writer_activity(). That message is not marked |
| 2171 | /// as an error, so we follow that lead and leave this as an |
| 2172 | /// informational message, guarded by debug level. This seems |
| 2173 | /// to be due to late samples (samples delivered after an |
| 2174 | /// association has been torn down). We may want to promote this |
| 2175 | /// to a warning if other conditions causing this symptom are |
| 2176 | /// discovered. |
| 2177 | ACE_DEBUG((LM_DEBUG, |
| 2178 | ACE_TEXT("(%P|%t) DataReaderImpl::process_latency() - ") |
| 2179 | ACE_TEXT("reader %C is not associated with writer %C (late sample?).\n"), |
| 2180 | LogGuid(get_guid()).c_str(), |
| 2181 | LogGuid(sample.header_.publication_id_).c_str())); |
| 2182 | } |
| 2183 | } |
| 2184 | |
| 2185 | void DataReaderImpl::notify_latency(GUID_t writer) |
| 2186 | { |
no test coverage detected