Re: [PATCH] gtask-helper: include functions to check coroutine context

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]