[Spice-devel] [PATCH] gtask-helper: include functions to check coroutine context
Christophe Fergeau
cfergeau at redhat.com
Tue May 17 15:21:14 UTC 2016
On Sat, May 14, 2016 at 05:03:37PM +0200, Victor Toso wrote:
> If we are in coroutine context, fallback to return in idle; Otherwise,
> let GTask decide if callback should be called or not.
> ---
> src/gtask-helper.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 45 insertions(+)
>
> diff --git a/src/gtask-helper.h b/src/gtask-helper.h
> index 81c041f..8771021 100644
> --- a/src/gtask-helper.h
> +++ b/src/gtask-helper.h
> @@ -29,6 +29,51 @@ void g_task_helper_return_error_in_idle(GTask *task, GError *error);
> void g_task_helper_return_new_error_in_idle(GTask *task, GQuark domain, gint code, const char *format, ...);
> void g_task_helper_return_pointer_in_idle(GTask *task, gpointer result, GDestroyNotify result_destroy);
>
> +#define g_task_helper_return_boolean(...) \
> + do { \
> + if (coroutine_self_is_main()) { \
> + g_task_return_boolean(__VA_ARGS__); \
> + } else { \
> + g_task_helper_return_boolean_in_idle(__VA_ARGS__); \
> + } \
> + } while (0)
Fwiw, glib has G_STMT_START and G_STMT_END which can be used instead of
do/while (0)
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20160517/733ee19d/attachment-0001.sig>
More information about the Spice-devel
mailing list