summaryrefslogtreecommitdiffstats
path: root/src/gio-coroutine.h
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2015-06-05 17:44:47 +0200
committerMarc-André Lureau <marcandre.lureau@redhat.com>2015-06-08 17:38:58 +0200
commitcaf28401cac9ece5e314360f8a3a54479df59727 (patch)
tree7ada0451442ffa1d9d056500ebd878ad80da3e06 /src/gio-coroutine.h
parent39c315241350dde3741c99fee4fff17b22d2b1fa (diff)
downloadspice-gtk-caf28401cac9ece5e314360f8a3a54479df59727.tar.gz
spice-gtk-caf28401cac9ece5e314360f8a3a54479df59727.tar.xz
spice-gtk-caf28401cac9ece5e314360f8a3a54479df59727.zip
Move gtk/ -> src/
For historical reasons, the code was placed under gtk/ subdirectory. If it was always bugging you, bug no more!
Diffstat (limited to 'src/gio-coroutine.h')
-rw-r--r--src/gio-coroutine.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/gio-coroutine.h b/src/gio-coroutine.h
new file mode 100644
index 0000000..b3a6d78
--- /dev/null
+++ b/src/gio-coroutine.h
@@ -0,0 +1,66 @@
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ Copyright (C) 2010 Red Hat, Inc.
+ Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws>
+ Copyright (C) 2009-2010 Daniel P. Berrange <dan@berrange.com>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.0 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+#ifndef __GIO_COROUTINE_H__
+#define __GIO_COROUTINE_H__
+
+#include <gio/gio.h>
+#include "coroutine.h"
+
+G_BEGIN_DECLS
+
+typedef struct _GCoroutine GCoroutine;
+
+struct _GCoroutine
+{
+ struct coroutine coroutine;
+ guint wait_id;
+ guint condition_id;
+};
+
+/*
+ * A special GSource impl which allows us to wait on a certain
+ * condition to be satisfied. This is effectively a boolean test
+ * run on each iteration of the main loop. So whenever a file has
+ * new I/O, or a timer occurs, etc we'll do the check. This is
+ * pretty efficient compared to a normal GLib Idle func which has
+ * to busy wait on a timeout, since our condition is only checked
+ * when some other source's state changes
+ */
+typedef gboolean (*GConditionWaitFunc)(gpointer);
+
+typedef void (*GSignalEmitMainFunc)(GObject *object, int signum, gpointer params);
+
+GCoroutine* g_coroutine_self (void);
+void g_coroutine_wakeup (GCoroutine *coroutine);
+GIOCondition g_coroutine_socket_wait (GCoroutine *coroutine,
+ GSocket *sock, GIOCondition cond);
+gboolean g_coroutine_condition_wait (GCoroutine *coroutine,
+ GConditionWaitFunc func, gpointer data);
+void g_coroutine_condition_cancel(GCoroutine *coroutine);
+
+void g_coroutine_signal_emit (gpointer instance, guint signal_id,
+ GQuark detail, ...);
+
+void g_coroutine_object_notify(GObject *object, const gchar *property_name);
+
+G_END_DECLS
+
+#endif /* __GIO_COROUTINE_H__ */