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