[Spice-devel] [PATCH 10/19] Introduce reds_core_timer_*

Frediano Ziglio fziglio at redhat.com
Fri Feb 19 12:31:15 UTC 2016


> 
> From: Christophe Fergeau <cfergeau at redhat.com>
> 
> ---
>  server/reds.c | 43 +++++++++++++++++++++++++++++++++++++++++++
>  server/reds.h | 11 +++++++++++
>  2 files changed, 54 insertions(+)
> 
> diff --git a/server/reds.c b/server/reds.c
> index 7006420..51092eb 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -4084,6 +4084,49 @@ void reds_core_watch_remove(RedsState *reds,
> SpiceWatch *watch)
>     reds->core->watch_remove(watch);
>  }
>  
> +SpiceTimer *reds_core_timer_add(RedsState *reds,
> +                                SpiceTimerFunc func,
> +                                void *opaque)
> +{
> +   g_return_val_if_fail(reds != NULL, NULL);
> +   g_return_val_if_fail(reds->core != NULL, NULL);
> +   g_return_val_if_fail(reds->core->timer_add != NULL, NULL);
> +
> +   return reds->core->timer_add(reds->core, func, opaque);
> +
> +}
> +
> +void reds_core_timer_start(RedsState *reds,
> +                           SpiceTimer *timer,
> +                           uint32_t ms)
> +{
> +   g_return_if_fail(reds != NULL);
> +   g_return_if_fail(reds->core != NULL);
> +   g_return_if_fail(reds->core->timer_start != NULL);
> +
> +   return reds->core->timer_start(timer, ms);
> +}
> +
> +void reds_core_timer_cancel(RedsState *reds,
> +                            SpiceTimer *timer)
> +{
> +   g_return_if_fail(reds != NULL);
> +   g_return_if_fail(reds->core != NULL);
> +   g_return_if_fail(reds->core->timer_cancel != NULL);
> +
> +   return reds->core->timer_cancel(timer);
> +}
> +
> +void reds_core_timer_remove(RedsState *reds,
> +                            SpiceTimer *timer)
> +{
> +   g_return_if_fail(reds != NULL);
> +   g_return_if_fail(reds->core != NULL);
> +   g_return_if_fail(reds->core->timer_remove != NULL);
> +
> +   return reds->core->timer_remove(timer);
> +}
> +
>  void reds_update_client_mouse_allowed(RedsState *reds)
>  {
>      static int allowed = FALSE;
> diff --git a/server/reds.h b/server/reds.h
> index 6dd0c81..174f48a 100644
> --- a/server/reds.h
> +++ b/server/reds.h
> @@ -127,4 +127,15 @@ void reds_core_watch_update_mask(RedsState *reds,
>                                   int event_mask);
>  void reds_core_watch_remove(RedsState *reds, SpiceWatch *watch);
>  
> +SpiceTimer *reds_core_timer_add(RedsState *reds,
> +                                SpiceTimerFunc func,
> +                                void *opaque);

I think would be really lovely if compiler could detect that
there is a mismatch between the opaque pointer and the
pointer the func function is expecting (I know how to do
this in C++, not really sure about C...).

> +void reds_core_timer_start(RedsState *reds,
> +                           SpiceTimer *timer,
> +                           uint32_t ms);
> +void reds_core_timer_cancel(RedsState *reds,
> +                            SpiceTimer *timer);
> +void reds_core_timer_remove(RedsState *reds,
> +                            SpiceTimer *timer);
> +
>  #endif

Frediano


More information about the Spice-devel mailing list