Skip to content

Commit a0edd7d

Browse files
committed
Due to review and discussion, _oneShotExpired removed again.
1 parent 9430a39 commit a0edd7d

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

cores/esp8266/PolledTimeout.h

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class timeoutTemplate
175175

176176
bool canWait () const
177177
{
178-
return _timeout != 0 && (PeriodicT || !_oneShotExpired);
178+
return _timeout != 0;
179179
}
180180

181181
// Resets, will trigger after this new timeout.
@@ -184,15 +184,14 @@ class timeoutTemplate
184184
{
185185
reset();
186186
_timeout = TimePolicyT::toTimeTypeUnit(newUserTimeout);
187-
_neverExpires = (newUserTimeout < 0) || (newUserTimeout > timeMax());
187+
_neverExpires = newUserTimeout > timeMax();
188188
}
189189

190190
// Resets, will trigger after the timeout previously set.
191191
IRAM_ATTR // called from ISR
192192
void reset()
193193
{
194194
_start = TimePolicyT::time();
195-
if (!PeriodicT) _oneShotExpired = false;
196195
}
197196

198197
// Resets to just expired so that on next poll the check will immediately trigger for the user,
@@ -216,7 +215,6 @@ class timeoutTemplate
216215
{
217216
_timeout = 1; // because canWait() has precedence
218217
_neverExpires = true;
219-
if (!PeriodicT) _oneShotExpired = false;
220218
}
221219

222220
void stop()
@@ -251,8 +249,8 @@ class timeoutTemplate
251249
bool checkExpired(const timeType internalUnit) const
252250
{
253251
// 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);
256254
}
257255

258256
protected:
@@ -277,19 +275,12 @@ class timeoutTemplate
277275
bool expiredOneShot() const
278276
{
279277
// 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());
287279
}
288280

289281
timeType _timeout;
290282
timeType _start;
291283
bool _neverExpires;
292-
mutable bool _oneShotExpired;
293284
};
294285

295286
// legacy type names, deprecated (unit is milliseconds)

0 commit comments

Comments
 (0)