@@ -177,7 +177,7 @@ class timeoutTemplate
177177
178178 bool canWait () const
179179 {
180- return _timeout != alwaysExpired;
180+ return _timeout != alwaysExpired && !_oneShotExpired ;
181181 }
182182
183183 // Resets, will trigger after this new timeout.
@@ -194,6 +194,7 @@ class timeoutTemplate
194194 void reset ()
195195 {
196196 _start = TimePolicyT::time ();
197+ _oneShotExpired = false ;
197198 }
198199
199200 // Resets to just expired so that on next poll the check will immediately trigger for the user,
@@ -246,8 +247,8 @@ class timeoutTemplate
246247 bool checkExpired (const timeType internalUnit) const
247248 {
248249 // canWait() is not checked here
249- // returns "can expire" and "time expired"
250- return (!_neverExpires) && ((internalUnit - _start) >= _timeout);
250+ // returns "can expire" and "oneshot not expired" and " time expired"
251+ return (_oneShotExpired) || (( !_neverExpires) && ((internalUnit - _start) >= _timeout) );
251252 }
252253
253254protected:
@@ -275,7 +276,7 @@ class timeoutTemplate
275276 if (!canWait ()) return true ;
276277 if (checkExpired (TimePolicyT::time ()))
277278 {
278- _timeout = alwaysExpired ;
279+ _oneShotExpired = true ;
279280 return true ;
280281 }
281282 return false ;
@@ -284,6 +285,7 @@ class timeoutTemplate
284285 timeType _timeout;
285286 timeType _start;
286287 bool _neverExpires;
288+ bool _oneShotExpired;
287289};
288290
289291// legacy type names, deprecated (unit is milliseconds)
0 commit comments