2
0

event_notifier-win32.c 986 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * event notifier support
  3. *
  4. * Copyright Red Hat, Inc. 2010
  5. *
  6. * Authors:
  7. * Michael S. Tsirkin <mst@redhat.com>
  8. *
  9. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  10. * See the COPYING file in the top-level directory.
  11. */
  12. #include "qemu/osdep.h"
  13. #include "qemu-common.h"
  14. #include "qemu/event_notifier.h"
  15. #include "qemu/main-loop.h"
  16. int event_notifier_init(EventNotifier *e, int active)
  17. {
  18. e->event = CreateEvent(NULL, TRUE, FALSE, NULL);
  19. assert(e->event);
  20. return 0;
  21. }
  22. void event_notifier_cleanup(EventNotifier *e)
  23. {
  24. CloseHandle(e->event);
  25. e->event = NULL;
  26. }
  27. HANDLE event_notifier_get_handle(EventNotifier *e)
  28. {
  29. return e->event;
  30. }
  31. int event_notifier_set(EventNotifier *e)
  32. {
  33. SetEvent(e->event);
  34. return 0;
  35. }
  36. int event_notifier_test_and_clear(EventNotifier *e)
  37. {
  38. int ret = WaitForSingleObject(e->event, 0);
  39. if (ret == WAIT_OBJECT_0) {
  40. ResetEvent(e->event);
  41. return true;
  42. }
  43. return false;
  44. }