callback.h File Reference

Provides a callback-with-argument event type. More...

Detailed Description

Provides a callback-with-argument event type.


void callback(void *arg)
printf("%s called with arg %p\n", __func__, arg);
event_callback_t event_callback = EVENT_CALLBACK_INIT(callback, 0x12345678);
event_post(&queue, &event_callback);
#define EVENT_CALLBACK_INIT(_cb, _arg)
Callback Event static initializer.
Definition: callback.h:96
#define printf(...)
A wrapper for the printf() function that passes arguments through unmodified, but fails to compile if...
Definition: stdio.h:60
void event_post(event_queue_t *queue, event_t *event)
Queue an event.
Callback Event structure definition.
Definition: callback.h:48

Event Callback API

Kaspar Schleiser

Definition in file callback.h.

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

Go to the source code of this file.

Data Structures

struct  event_callback_t
 Callback Event structure definition. More...
#define EVENT_CALLBACK_INIT(_cb, _arg)
 Callback Event static initializer. More...
void event_callback_init (event_callback_t *event_callback, void(*callback)(void *), void *arg)
 event callback initialization function More...
static void event_callback_oneshot (event_callback_t *event, event_queue_t *queue, void(*callback)(void *), void *arg)
 Generate a one-shot callback event on queue. More...
void _event_callback_handler (event_t *event)
 event callback handler function (used internally)

Macro Definition Documentation


#define EVENT_CALLBACK_INIT (   _cb,
{ \
.super.handler = _event_callback_handler, \
.callback = _cb, \
.arg = (void *)_arg \
void _event_callback_handler(event_t *event)
event callback handler function (used internally)

Callback Event static initializer.

[in]_cbcallback function to set
[in]_argarguments to set

Definition at line 96 of file callback.h.

Function Documentation

◆ event_callback_init()

void event_callback_init ( event_callback_t event_callback,
void(*)(void *)  callback,
void *  arg 

event callback initialization function

[out]event_callbackobject to initialize
[in]callbackcallback to set up
[in]argcallback argument to set up

◆ event_callback_oneshot()

static void event_callback_oneshot ( event_callback_t event,
event_queue_t queue,
void(*)(void *)  callback,
void *  arg 

Generate a one-shot callback event on queue.

This will initialize event and post it immediately

[in]eventevent_callback object to initialize
[in]queuequeue that the event will be added to
[in]callbackcallback to set up
[in]argcallback argument to set up

Definition at line 73 of file callback.h.