mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-16 21:26:43 +08:00
timeouts: sys_check_timeouts: return wait time for next loop
see patch #10133 So that can do: void my_loop() { long timeout; while (1) { timeout = sys_check_timeouts(); if (timeout == SYS_TIMEOUTS_SLEEPTIME_INFINITE) timeout = 100; WaitForEvent(timeout); } } Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
This commit is contained in:
committed by
Simon Goldschmidt
parent
5d32779c1b
commit
0c3a93efe3
@@ -347,8 +347,11 @@ sys_untimeout(sys_timeout_handler handler, void *arg)
|
||||
* handler functions when timeouts expire.
|
||||
*
|
||||
* Must be called periodically from your main loop.
|
||||
*
|
||||
* @return the time left before the next timeout is due. If no timeouts are
|
||||
* enqueued, returns 0xffffffff
|
||||
*/
|
||||
void
|
||||
u32_t
|
||||
sys_check_timeouts(void)
|
||||
{
|
||||
u32_t now;
|
||||
@@ -367,11 +370,13 @@ sys_check_timeouts(void)
|
||||
|
||||
tmptimeout = next_timeout;
|
||||
if (tmptimeout == NULL) {
|
||||
return;
|
||||
return SYS_TIMEOUTS_SLEEPTIME_INFINITE;
|
||||
}
|
||||
|
||||
if (TIME_LESS_THAN(now, tmptimeout->time)) {
|
||||
return;
|
||||
u32_t ret = (u32_t)(tmptimeout->time - now);
|
||||
LWIP_ASSERT("invalid sleeptime", ret <= LWIP_MAX_TIMEOUT);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Timeout has expired */
|
||||
|
||||
@@ -111,7 +111,7 @@ void sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg);
|
||||
|
||||
void sys_untimeout(sys_timeout_handler handler, void *arg);
|
||||
void sys_restart_timeouts(void);
|
||||
void sys_check_timeouts(void);
|
||||
u32_t sys_check_timeouts(void);
|
||||
u32_t sys_timeouts_sleeptime(void);
|
||||
|
||||
#if LWIP_TESTMODE
|
||||
|
||||
Reference in New Issue
Block a user