qemu-io: Use bdrv_drain_all instead of qemu_aio_flush
[qemu/ar7.git] / event_notifier-win32.c
blobc723dadf3134229cc9f7cba5531363a1a6bbd84e
1 /*
2 * event notifier support
4 * Copyright Red Hat, Inc. 2010
6 * Authors:
7 * Michael S. Tsirkin <mst@redhat.com>
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.
13 #include "qemu-common.h"
14 #include "event_notifier.h"
15 #include "main-loop.h"
17 int event_notifier_init(EventNotifier *e, int active)
19 e->event = CreateEvent(NULL, FALSE, FALSE, NULL);
20 assert(e->event);
21 return 0;
24 void event_notifier_cleanup(EventNotifier *e)
26 CloseHandle(e->event);
29 HANDLE event_notifier_get_handle(EventNotifier *e)
31 return e->event;
34 int event_notifier_set_handler(EventNotifier *e,
35 EventNotifierHandler *handler)
37 if (handler) {
38 return qemu_add_wait_object(e->event, (IOHandler *)handler, e);
39 } else {
40 qemu_del_wait_object(e->event, (IOHandler *)handler, e);
41 return 0;
45 int event_notifier_set(EventNotifier *e)
47 SetEvent(e->event);
48 return 0;
51 int event_notifier_test_and_clear(EventNotifier *e)
53 int ret = WaitForSingleObject(e->event, 0);
54 if (ret == WAIT_OBJECT_0) {
55 ResetEvent(e->event);
56 return true;
58 return false;