From 9b8d62089cb56e10b9fa9a875dd318a8a0c827ae Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 18 Jul 2016 18:01:01 +0100 Subject: [PATCH] Make the reflector polling time dynamic. --- YSFGateway/Reflectors.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/YSFGateway/Reflectors.cpp b/YSFGateway/Reflectors.cpp index 09dfb82..4d8f582 100644 --- a/YSFGateway/Reflectors.cpp +++ b/YSFGateway/Reflectors.cpp @@ -34,7 +34,7 @@ m_reflectors(), m_it(), m_current(), m_search(), -m_timer(1000U, 15U) +m_timer(1000U, 30U) { assert(statusPort > 0U); } @@ -71,6 +71,18 @@ bool CReflectors::load() m_it = m_reflectors.begin(); + // Make the polling time based on the number of reflectors within limits + unsigned int nReflectors = m_reflectors.size(); + if (nReflectors > 0U) { + unsigned int t = 600U / nReflectors; + if (t > 30U) + t = 30U; + else if (t < 15U) + t = 15U; + + m_timer.setTimeout(t); + } + m_timer.start(); return true;