summaryrefslogtreecommitdiffstats
path: root/hw/dataplane/event-poll.h
blob: 3e8d3ec7d59a7c82137a6b9eda834a25379615e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * Event loop with file descriptor polling
 *
 * Copyright 2012 IBM, Corp.
 * Copyright 2012 Red Hat, Inc. and/or its affiliates
 *
 * Authors:
 *   Stefan Hajnoczi <stefanha@redhat.com>
 *
 * This work is licensed under the terms of the GNU GPL, version 2 or later.
 * See the COPYING file in the top-level directory.
 *
 */

#ifndef EVENT_POLL_H
#define EVENT_POLL_H

#include "qemu/event_notifier.h"

typedef struct EventHandler EventHandler;
typedef void EventCallback(EventHandler *handler);
struct EventHandler {
    EventNotifier *notifier;        /* eventfd */
    EventCallback *callback;        /* callback function */
};

typedef struct {
    int epoll_fd;                   /* epoll(2) file descriptor */
    EventNotifier stop_notifier;    /* stop poll notifier */
    EventHandler stop_handler;      /* stop poll handler */
} EventPoll;

void event_poll_add(EventPoll *poll, EventHandler *handler,
                    EventNotifier *notifier, EventCallback *callback);
void event_poll_init(EventPoll *poll);
void event_poll_cleanup(EventPoll *poll);
void event_poll(EventPoll *poll);
void event_poll_notify(EventPoll *poll);

#endif /* EVENT_POLL_H */
OpenPOWER on IntegriCloud