dataplane: add event loop
[qemu/kevin.git] / hw / dataplane / event-poll.h
blob3e8d3ec7d59a7c82137a6b9eda834a25379615e3
1 /*
2 * Event loop with file descriptor polling
4 * Copyright 2012 IBM, Corp.
5 * Copyright 2012 Red Hat, Inc. and/or its affiliates
7 * Authors:
8 * Stefan Hajnoczi <stefanha@redhat.com>
10 * This work is licensed under the terms of the GNU GPL, version 2 or later.
11 * See the COPYING file in the top-level directory.
15 #ifndef EVENT_POLL_H
16 #define EVENT_POLL_H
18 #include "qemu/event_notifier.h"
20 typedef struct EventHandler EventHandler;
21 typedef void EventCallback(EventHandler *handler);
22 struct EventHandler {
23 EventNotifier *notifier; /* eventfd */
24 EventCallback *callback; /* callback function */
27 typedef struct {
28 int epoll_fd; /* epoll(2) file descriptor */
29 EventNotifier stop_notifier; /* stop poll notifier */
30 EventHandler stop_handler; /* stop poll handler */
31 } EventPoll;
33 void event_poll_add(EventPoll *poll, EventHandler *handler,
34 EventNotifier *notifier, EventCallback *callback);
35 void event_poll_init(EventPoll *poll);
36 void event_poll_cleanup(EventPoll *poll);
37 void event_poll(EventPoll *poll);
38 void event_poll_notify(EventPoll *poll);
40 #endif /* EVENT_POLL_H */