block/iscsi: Introducing new zero-copy API
[qemu/ar7.git] / util / event_notifier-win32.c
blobde87df02d67922f3adf1e8cce7da573b8d83d406
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/osdep.h"
14 #include "qemu-common.h"
15 #include "qemu/event_notifier.h"
16 #include "qemu/main-loop.h"
18 int event_notifier_init(EventNotifier *e, int active)
20 e->event = CreateEvent(NULL, TRUE, FALSE, NULL);
21 assert(e->event);
22 return 0;
25 void event_notifier_cleanup(EventNotifier *e)
27 CloseHandle(e->event);
30 HANDLE event_notifier_get_handle(EventNotifier *e)
32 return e->event;
35 int event_notifier_set_handler(EventNotifier *e,
36 bool is_external,
37 EventNotifierHandler *handler)
39 if (handler) {
40 return qemu_add_wait_object(e->event, (IOHandler *)handler, e);
41 } else {
42 qemu_del_wait_object(e->event, (IOHandler *)handler, e);
43 return 0;
47 int event_notifier_set(EventNotifier *e)
49 SetEvent(e->event);
50 return 0;
53 int event_notifier_test_and_clear(EventNotifier *e)
55 int ret = WaitForSingleObject(e->event, 0);
56 if (ret == WAIT_OBJECT_0) {
57 ResetEvent(e->event);
58 return true;
60 return false;