@@ -176,7 +176,7 @@ class timeoutTemplate
176
176
177
177
bool canWait () const
178
178
{
179
- return !( _timeout == 0 || _oneShotExpired);
179
+ return _timeout != 0 && (PeriodicT || ! _oneShotExpired);
180
180
}
181
181
182
182
// Resets, will trigger after this new timeout.
@@ -193,7 +193,7 @@ class timeoutTemplate
193
193
void reset ()
194
194
{
195
195
_start = TimePolicyT::time ();
196
- _oneShotExpired = false ;
196
+ if (!PeriodicT) _oneShotExpired = false ;
197
197
}
198
198
199
199
// Resets to just expired so that on next poll the check will immediately trigger for the user,
@@ -217,6 +217,12 @@ class timeoutTemplate
217
217
{
218
218
_timeout = 1 ; // because canWait() has precedence
219
219
_neverExpires = true ;
220
+ if (!PeriodicT) _oneShotExpired = false ;
221
+ }
222
+
223
+ void stop ()
224
+ {
225
+ resetToNeverExpires ();
220
226
}
221
227
222
228
timeType getTimeout () const
@@ -247,7 +253,7 @@ class timeoutTemplate
247
253
{
248
254
// canWait() is not checked here
249
255
// returns "oneshot has expired", otherwise returns "can expire" and "time has expired"
250
- return _oneShotExpired || (!_neverExpires && ((internalUnit - _start) >= _timeout));
256
+ return !_neverExpires && ((!PeriodicT && _oneShotExpired) || ((internalUnit - _start) >= _timeout));
251
257
}
252
258
253
259
protected:
@@ -275,7 +281,7 @@ class timeoutTemplate
275
281
if (!canWait ()) return true ;
276
282
if (checkExpired (TimePolicyT::time ()))
277
283
{
278
- _oneShotExpired = true ;
284
+ if (!PeriodicT) _oneShotExpired = true ;
279
285
return true ;
280
286
}
281
287
return false ;
0 commit comments