event-poll.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Event loop with file descriptor polling
  3. *
  4. * Copyright 2012 IBM, Corp.
  5. * Copyright 2012 Red Hat, Inc. and/or its affiliates
  6. *
  7. * Authors:
  8. * Stefan Hajnoczi <stefanha@redhat.com>
  9. *
  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.
  12. *
  13. */
  14. #ifndef EVENT_POLL_H
  15. #define EVENT_POLL_H
  16. #include "qemu/event_notifier.h"
  17. typedef struct EventHandler EventHandler;
  18. typedef void EventCallback(EventHandler *handler);
  19. struct EventHandler {
  20. EventNotifier *notifier; /* eventfd */
  21. EventCallback *callback; /* callback function */
  22. };
  23. typedef struct {
  24. int epoll_fd; /* epoll(2) file descriptor */
  25. EventNotifier stop_notifier; /* stop poll notifier */
  26. EventHandler stop_handler; /* stop poll handler */
  27. } EventPoll;
  28. void event_poll_add(EventPoll *poll, EventHandler *handler,
  29. EventNotifier *notifier, EventCallback *callback);
  30. void event_poll_init(EventPoll *poll);
  31. void event_poll_cleanup(EventPoll *poll);
  32. void event_poll(EventPoll *poll);
  33. void event_poll_notify(EventPoll *poll);
  34. #endif /* EVENT_POLL_H */