diff mbox

[uq/master,1/9] event_notifier: add event_notifier_set

Message ID 1341501390-797-2-git-send-email-pbonzini@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Paolo Bonzini July 5, 2012, 3:16 p.m. UTC
EventNotifier right now cannot be used as an inter-thread communication
primitive.  It only works if something else (the kernel) sets the eventfd.
Add a primitive to signal an EventNotifier that another thread is waiting
on.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 event_notifier.c |    7 +++++++
 event_notifier.h |    1 +
 2 files changed, 8 insertions(+)
diff mbox

Patch

diff --git a/event_notifier.c b/event_notifier.c
index 0b82981..2b210f4 100644
--- a/event_notifier.c
+++ b/event_notifier.c
@@ -38,6 +38,13 @@  int event_notifier_get_fd(EventNotifier *e)
     return e->fd;
 }
 
+int event_notifier_set(EventNotifier *e)
+{
+    uint64_t value = 1;
+    int r = write(e->fd, &value, sizeof(value));
+    return r == sizeof(value);
+}
+
 int event_notifier_test_and_clear(EventNotifier *e)
 {
     uint64_t value;
diff --git a/event_notifier.h b/event_notifier.h
index 886222c..efca852 100644
--- a/event_notifier.h
+++ b/event_notifier.h
@@ -22,6 +22,7 @@  struct EventNotifier {
 int event_notifier_init(EventNotifier *, int active);
 void event_notifier_cleanup(EventNotifier *);
 int event_notifier_get_fd(EventNotifier *);
+int event_notifier_set(EventNotifier *);
 int event_notifier_test_and_clear(EventNotifier *);
 int event_notifier_test(EventNotifier *);