@@ -175,7 +175,7 @@ class timeoutTemplate
175175
176176 bool canWait () const
177177 {
178- return !( _timeout == 0 || _oneShotExpired);
178+ return _timeout != 0 && (PeriodicT || ! _oneShotExpired);
179179 }
180180
181181 // Resets, will trigger after this new timeout.
@@ -192,7 +192,7 @@ class timeoutTemplate
192192 void reset ()
193193 {
194194 _start = TimePolicyT::time ();
195- _oneShotExpired = false ;
195+ if (!PeriodicT) _oneShotExpired = false ;
196196 }
197197
198198 // Resets to just expired so that on next poll the check will immediately trigger for the user,
@@ -216,6 +216,12 @@ class timeoutTemplate
216216 {
217217 _timeout = 1 ; // because canWait() has precedence
218218 _neverExpires = true ;
219+ if (!PeriodicT) _oneShotExpired = false ;
220+ }
221+
222+ void stop ()
223+ {
224+ resetToNeverExpires ();
219225 }
220226
221227 timeType getTimeout () const
@@ -246,7 +252,7 @@ class timeoutTemplate
246252 {
247253 // canWait() is not checked here
248254 // returns "oneshot has expired", otherwise returns "can expire" and "time has expired"
249- return _oneShotExpired || (!_neverExpires && ((internalUnit - _start) >= _timeout));
255+ return !_neverExpires && ((!PeriodicT && _oneShotExpired) || ((internalUnit - _start) >= _timeout));
250256 }
251257
252258protected:
@@ -274,7 +280,7 @@ class timeoutTemplate
274280 if (!canWait ()) return true ;
275281 if (checkExpired (TimePolicyT::time ()))
276282 {
277- _oneShotExpired = true ;
283+ if (!PeriodicT) _oneShotExpired = true ;
278284 return true ;
279285 }
280286 return false ;
0 commit comments