[Hardware OS Event Interface] Notify and handle events between threads. More...
#include "hstructures.h"
Go to the source code of this file.
Defines | |
#define | HEVENT_BLOCKING 1 |
#define | HEVENT_NONBLOCKING 0 |
Functions | |
struct hevent * | hevent_create (int blocking) |
Creates an event handler. | |
int | hevent_notify (struct hevent *event, int notification) |
Notify an event. | |
int | hevent_wait (struct hevent *event) |
Wait on event. | |
int | hevent_remove (struct hevent *event) |
Remove an event handler. |
[Hardware OS Event Interface] Notify and handle events between threads.
This module contains functionality for handling events between threads. Events can be handled both blocking (asynchronously) or non-blocking (synchronously). The underlying implemenation use System V message queues.
Author (2011): Sindre Hansen
Definition in file hevent.h.
struct hevent* hevent_create | ( | int | blocking | ) | [read] |
Creates an event handler.
async | Set to true if hevent_wait should block while waiting for events. |
int hevent_notify | ( | struct hevent * | event, | |
int | notification | |||
) |
Notify an event.
event | Event handler. | |
notification | The actual event/notification. Must be an integer. |
Definition at line 39 of file hevent.c.
{ if (event == NULL) return -1; struct hevent_msg msg; msg.mtype = 1; msg.mtext = notification; if (msgsnd(event->msqid, &msg, sizeof(msg.mtext), 0) == -1) return -1; return 0; }
int hevent_remove | ( | struct hevent * | event | ) |
int hevent_wait | ( | struct hevent * | event | ) |
Wait on event.
Wait may be performed in a blocking or non-blocking manner (see hevent_create).
event | Event handler. |
Definition at line 54 of file hevent.c.
{ if (event == NULL) return -1; struct hevent_msg msg; int msgflg = IPC_NOWAIT; if (event->blocking) msgflg = 0; if (msgrcv(event->msqid, &msg, sizeof(msg.mtext), 0, msgflg) == -1) return -1; return msg.mtext; }