@@ -176,7 +176,7 @@ class timeoutTemplate
176
176
177
177
bool canWait () const
178
178
{
179
- return _timeout != 0 && (PeriodicT || !_oneShotExpired) ;
179
+ return _timeout != 0 ;
180
180
}
181
181
182
182
// Resets, will trigger after this new timeout.
@@ -185,15 +185,14 @@ class timeoutTemplate
185
185
{
186
186
reset ();
187
187
_timeout = TimePolicyT::toTimeTypeUnit (newUserTimeout);
188
- _neverExpires = ( newUserTimeout < 0 ) || (newUserTimeout > timeMax () );
188
+ _neverExpires = newUserTimeout > timeMax ();
189
189
}
190
190
191
191
// Resets, will trigger after the timeout previously set.
192
192
IRAM_ATTR // called from ISR
193
193
void reset ()
194
194
{
195
195
_start = TimePolicyT::time ();
196
- if (!PeriodicT) _oneShotExpired = false ;
197
196
}
198
197
199
198
// Resets to just expired so that on next poll the check will immediately trigger for the user,
@@ -217,7 +216,6 @@ class timeoutTemplate
217
216
{
218
217
_timeout = 1 ; // because canWait() has precedence
219
218
_neverExpires = true ;
220
- if (!PeriodicT) _oneShotExpired = false ;
221
219
}
222
220
223
221
void stop ()
@@ -252,8 +250,8 @@ class timeoutTemplate
252
250
bool checkExpired (const timeType internalUnit) const
253
251
{
254
252
// 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);
257
255
}
258
256
259
257
protected:
@@ -278,19 +276,12 @@ class timeoutTemplate
278
276
bool expiredOneShot () const
279
277
{
280
278
// 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 ());
288
280
}
289
281
290
282
timeType _timeout;
291
283
timeType _start;
292
284
bool _neverExpires;
293
- mutable bool _oneShotExpired;
294
285
};
295
286
296
287
// legacy type names, deprecated (unit is milliseconds)
0 commit comments