diff --git a/idd/LGIdd/transport/CInputHub.cpp b/idd/LGIdd/transport/CInputHub.cpp index 5116515f..f5183270 100644 --- a/idd/LGIdd/transport/CInputHub.cpp +++ b/idd/LGIdd/transport/CInputHub.cpp @@ -22,16 +22,12 @@ #include "input/IInputSink.h" -static bool SameSource(const SourceKey& left, const SourceKey& right) -{ - return left.backend == right.backend && left.epoch == right.epoch && - left.client == right.client && left.generation == right.generation; -} - static bool SameClient(const SourceKey& left, const SourceKey& right) { - return left.backend == right.backend && left.epoch == right.epoch && - left.client == right.client; + return + left.backend == right.backend && + left.epoch == right.epoch && + left.client == right.client; } CInputHub::CInputHub() @@ -307,7 +303,7 @@ void CInputHub::CommitInteraction( const SourceKey& source, const InteractionPermit& permit) { if (!source.backend || !source.epoch || !source.client || !permit.serial || - !SameSource(source, permit.source)) + source != permit.source) return; CSRWExclusiveLock lock(m_lock); @@ -497,7 +493,7 @@ bool CInputHub::BindingPresent(const SourceKey& source) const bool CInputHub::OwnerValid(const SourceKey& source) const { - return SourceValid(source) && SameSource(m_owner, source); + return SourceValid(source) && m_owner == source; } void CInputHub::ClearInteraction() @@ -558,8 +554,7 @@ InputTargetState CInputHub::GetState(const SourceKey& source) return result; if (!m_owner.backend) result.available = true; - else if (source.client && source.generation && - SameSource(m_owner, source)) + else if (source.client && source.generation && m_owner == source) { result.available = true; result.owned = true; @@ -600,7 +595,7 @@ InputResult CInputHub::Claim(const SourceKey& source) if (!CheckState()) return InputResult::UNAVAILABLE; if (m_owner.backend) - return SameSource(m_owner, source) ? + return m_owner == source ? InputResult::ACCEPTED : InputResult::BUSY; if (!m_sink->Reset() || m_sink->GetState() != m_sinkState) { diff --git a/idd/LGIdd/transport/CRecoveryHub.cpp b/idd/LGIdd/transport/CRecoveryHub.cpp index 45d3e7d6..cd6ae584 100644 --- a/idd/LGIdd/transport/CRecoveryHub.cpp +++ b/idd/LGIdd/transport/CRecoveryHub.cpp @@ -45,13 +45,6 @@ CRecoveryHub::CRecoveryHub() : { } -bool CRecoveryHub::SameSource( - const SourceKey& left, const SourceKey& right) -{ - return left.backend == right.backend && left.epoch == right.epoch && - left.client == right.client && left.generation == right.generation; -} - bool CRecoveryHub::SameEpoch( const SourceKey& source, BackendId backend, uint32_t epoch) { @@ -61,7 +54,7 @@ bool CRecoveryHub::SameEpoch( bool CRecoveryHub::SameRequest(const Request& request, const SourceKey& source, uint64_t session, uint32_t serial, bool active) { - return SameSource(request.source, source) && request.session == session && + return request.source == source && request.session == session && request.serial == serial && request.active == active; } @@ -83,7 +76,7 @@ unsigned CRecoveryHub::FindSourceLocked(const SourceKey& source) const { for (unsigned i = 0; i < MAX_REQUESTS; ++i) if (m_requests[i].state != SlotState::FREE && - SameSource(m_requests[i].source, source)) + m_requests[i].source == source) return i; return MAX_REQUESTS; } diff --git a/idd/LGIdd/transport/CRecoveryHub.h b/idd/LGIdd/transport/CRecoveryHub.h index 793a6baa..d5e6a968 100644 --- a/idd/LGIdd/transport/CRecoveryHub.h +++ b/idd/LGIdd/transport/CRecoveryHub.h @@ -96,7 +96,6 @@ private: bool m_knownValid = false; bool m_monitorReady = false; - static bool SameSource(const SourceKey& left, const SourceKey& right); static bool SameEpoch( const SourceKey& source, BackendId backend, uint32_t epoch); static bool SameRequest(const Request& request, const SourceKey& source, diff --git a/idd/LGIdd/transport/ITransport.h b/idd/LGIdd/transport/ITransport.h index dfccf0db..c3913fca 100644 --- a/idd/LGIdd/transport/ITransport.h +++ b/idd/LGIdd/transport/ITransport.h @@ -40,6 +40,20 @@ struct SourceKey uint32_t generation = 0; }; +inline bool operator==(const SourceKey& left, const SourceKey& right) +{ + return + left.backend == right.backend && + left.epoch == right.epoch && + left.client == right.client && + left.generation == right.generation; +} + +inline bool operator!=(const SourceKey& left, const SourceKey& right) +{ + return !(left == right); +} + enum class InteractionResult { ACCEPTED,