Skip to content

Commit 8264260

Browse files
Added etimer_next_to_expire function
Added the etimer_next_to_expire function as a superior version of etimer_next_expiration_time; the major benefits being: 1. We return NULL if no timers remaining 2. we can use the timer module functions to determine if the timer is expired, how long until it expires etc.
1 parent 5a97cbf commit 8264260

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

core/sys/etimer.c

+6
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,12 @@ etimer_next_expiration_time(void)
254254
return etimer_pending() ? next_expiration : 0;
255255
}
256256
/*---------------------------------------------------------------------------*/
257+
const struct timer *
258+
etimer_next_to_expire(void)
259+
{
260+
return timerlist ? &(timerlist->timer) : NULL;
261+
}
262+
/*---------------------------------------------------------------------------*/
257263
void
258264
etimer_stop(struct etimer *et)
259265
{

core/sys/etimer.h

+11
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,17 @@ int etimer_pending(void);
245245
*/
246246
clock_time_t etimer_next_expiration_time(void);
247247

248+
/**
249+
* \brief Return the timer which is next to expire
250+
* \return Const pointer to timer which will next expire, or NULL if no
251+
* timers pending.
252+
*
253+
* This function returns the timer of the etimer which will expire
254+
* next so that existing timer module functions can be used to
255+
* check when the timer will expire or if it has already expired.
256+
*/
257+
const struct timer *etimer_next_to_expire(void);
258+
248259
#define etimer_lt(t0, t1, c) timer_lt(&(t0->timer), &(t1->timer), c)
249260
#define etimer_lte(t0, t1, c) timer_lte(&(t0->timer), &(t1->timer), c)
250261
#define etimer_gt(t0, t1, c) timer_gt(&(t0->timer), &(t1->timer), c)

0 commit comments

Comments
 (0)