timeout.h File Reference

Provides functionality to trigger events after timeout. More...

Detailed Description

Provides functionality to trigger events after timeout.

event_timeout intentionally doesn't extend event structures in order to support events that are integrated in larger structs intrusively.

Example:

event_timeout_t event_timeout;
printf("posting timed callback with timeout 1sec\n");
event_timeout_init(&event_timeout, &queue, (event_t*)&event);
event_timeout_set(&event_timeout, 1000000);
[...]

Event Timeout API

Author
Kaspar Schleiser kaspa.nosp@m.r@sc.nosp@m.hleis.nosp@m.er.d.nosp@m.e

Definition in file timeout.h.

#include "event.h"
#include "xtimer.h"
+ Include dependency graph for timeout.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  event_timeout_t
 Timeout Event structure. More...
 
void event_timeout_init (event_timeout_t *event_timeout, event_queue_t *queue, event_t *event)
 Initialize timeout event object. More...
 
void event_timeout_set (event_timeout_t *event_timeout, uint32_t timeout)
 Set a timeout. More...
 
void event_timeout_clear (event_timeout_t *event_timeout)
 Clear a timeout event. More...
 

Function Documentation

◆ event_timeout_clear()

void event_timeout_clear ( event_timeout_t event_timeout)

Clear a timeout event.

Calling this function will cancel the timeout by removing its underlying timer. If the timer has already fired before calling this function, the connected event will be put already into the given event queue and this function does not have any effect.

Parameters
[in]event_timeoutevent_timeout context object to use

◆ event_timeout_init()

void event_timeout_init ( event_timeout_t event_timeout,
event_queue_t queue,
event_t event 
)

Initialize timeout event object.

Parameters
[in]event_timeoutevent_timeout object to initialize
[in]queuequeue that the timed-out event will be added to
[in]eventevent to add to queue after timeout

◆ event_timeout_set()

void event_timeout_set ( event_timeout_t event_timeout,
uint32_t  timeout 
)

Set a timeout.

This will make the event as configured in event_timeout be triggered after timeout microseconds.

Note
: the used event_timeout struct must stay valid until after the timeout event has been processed!
Parameters
[in]event_timeoutevent_timout context object to use
[in]timeouttimeout in microseconds
event_timeout_t
Timeout Event structure.
Definition: timeout.h:50
event
event structure
Definition: event.h:142
event_timeout_init
void event_timeout_init(event_timeout_t *event_timeout, event_queue_t *queue, event_t *event)
Initialize timeout event object.
event_timeout_set
void event_timeout_set(event_timeout_t *event_timeout, uint32_t timeout)
Set a timeout.