Merge pull request #862 from tadodotcom/ctimer-set-process

feat(ctimer): API extension to explictly state the process a ctimer belongs to
This commit is contained in:
Adam Dunkels 2015-08-31 11:51:32 +02:00
commit 023deaf49f
2 changed files with 26 additions and 1 deletions

View File

@ -98,9 +98,16 @@ ctimer_init(void)
void
ctimer_set(struct ctimer *c, clock_time_t t,
void (*f)(void *), void *ptr)
{
ctimer_set_with_process(c, t, f, ptr, PROCESS_CURRENT());
}
/*---------------------------------------------------------------------------*/
void
ctimer_set_with_process(struct ctimer *c, clock_time_t t,
void (*f)(void *), void *ptr, struct process *p)
{
PRINTF("ctimer_set %p %u\n", c, (unsigned)t);
c->p = PROCESS_CURRENT();
c->p = p;
c->f = f;
c->ptr = ptr;
if(initialized) {

View File

@ -109,10 +109,28 @@ void ctimer_restart(struct ctimer *c);
* sometime in the future. When the callback timer expires,
* the callback function f will be called with ptr as argument.
*
* This essentially does ctimer_set_process(c, t, f, ptr, PROCESS_CURRENT());
*
*/
void ctimer_set(struct ctimer *c, clock_time_t t,
void (*f)(void *), void *ptr);
/**
* \brief Set a callback timer.
* \param c A pointer to the callback timer.
* \param t The interval before the timer expires.
* \param f A function to be called when the timer expires.
* \param ptr An opaque pointer that will be supplied as an argument to the callback function.
* \param p A pointer to the process the timer belongs to
*
* This function is used to set a callback timer for a time
* sometime in the future. When the callback timer expires,
* the callback function f will be called with ptr as argument.
*
*/
void ctimer_set_with_process(struct ctimer *c, clock_time_t t,
void (*f)(void *), void *ptr, struct process *p);
/**
* \brief Stop a pending callback timer.
* \param c A pointer to the pending callback timer.