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