@@ -176,7 +176,7 @@ class timeoutTemplate
176176
177177 bool canWait () const
178178 {
179- return _timeout != 0 && (PeriodicT || !_oneShotExpired) ;
179+ return _timeout != 0 ;
180180 }
181181
182182 // Resets, will trigger after this new timeout.
@@ -185,15 +185,14 @@ class timeoutTemplate
185185 {
186186 reset ();
187187 _timeout = TimePolicyT::toTimeTypeUnit (newUserTimeout);
188- _neverExpires = ( newUserTimeout < 0 ) || (newUserTimeout > timeMax () );
188+ _neverExpires = newUserTimeout > timeMax ();
189189 }
190190
191191 // Resets, will trigger after the timeout previously set.
192192 IRAM_ATTR // called from ISR
193193 void reset ()
194194 {
195195 _start = TimePolicyT::time ();
196- if (!PeriodicT) _oneShotExpired = false ;
197196 }
198197
199198 // Resets to just expired so that on next poll the check will immediately trigger for the user,
@@ -217,7 +216,6 @@ class timeoutTemplate
217216 {
218217 _timeout = 1 ; // because canWait() has precedence
219218 _neverExpires = true ;
220- if (!PeriodicT) _oneShotExpired = false ;
221219 }
222220
223221 void stop ()
@@ -252,8 +250,8 @@ class timeoutTemplate
252250 bool checkExpired (const timeType internalUnit) const
253251 {
254252 // canWait() is not checked here
255- // returns "oneshot has expired", otherwise returns " can expire" and "time has expired"
256- return !_neverExpires && ((!PeriodicT && _oneShotExpired) || (( internalUnit - _start) >= _timeout) );
253+ // returns "can expire" and "time has expired"
254+ return ( !_neverExpires) && ((internalUnit - _start) >= _timeout);
257255 }
258256
259257protected:
@@ -278,19 +276,12 @@ class timeoutTemplate
278276 bool expiredOneShot () const
279277 {
280278 // returns "always expired" or "has expired"
281- if (!canWait ()) return true ;
282- if (checkExpired (TimePolicyT::time ()))
283- {
284- if (!PeriodicT) _oneShotExpired = true ;
285- return true ;
286- }
287- return false ;
279+ return !canWait () || checkExpired (TimePolicyT::time ());
288280 }
289281
290282 timeType _timeout;
291283 timeType _start;
292284 bool _neverExpires;
293- mutable bool _oneShotExpired;
294285};
295286
296287// legacy type names, deprecated (unit is milliseconds)
0 commit comments