From 271bb6fc606fc5068a7b7a8f22b0052aca2fb900 Mon Sep 17 00:00:00 2001 From: José Bollo Date: Thu, 21 Sep 2017 12:34:12 +0200 Subject: Make afb_event_drop obsolete MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The function is now replaced by the function afb_event_unref. In the same time, the function afb_event_addref is made available. Change-Id: I9aa30e80e64e82f3b16ab359982337771b287185 Signed-off-by: José Bollo --- include/afb/afb-binding.hpp | 6 ++++-- include/afb/afb-event-itf.h | 31 ++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/afb/afb-binding.hpp b/include/afb/afb-binding.hpp index 1fc8b497..6e062b2e 100644 --- a/include/afb/afb-binding.hpp +++ b/include/afb/afb-binding.hpp @@ -110,7 +110,8 @@ public: int broadcast(json_object *object) const; int push(json_object *object) const; - void drop(); + void unref(); + void addref(); const char *name() const; }; @@ -261,7 +262,8 @@ inline void event::invalidate() { event_.itf = NULL; event_.closure = NULL; } inline int event::broadcast(json_object *object) const { return afb_event_broadcast(event_, object); } inline int event::push(json_object *object) const { return afb_event_push(event_, object); } -inline void event::drop() { afb_event_drop(event_); invalidate(); } +inline void event::unref() { afb_event_unref(event_); invalidate(); } +inline void event::addref() { afb_event_addref(event_); } inline const char *event::name() const { return afb_event_name(event_); } /* args */ diff --git a/include/afb/afb-event-itf.h b/include/afb/afb-event-itf.h index b1776ea0..6827d86a 100644 --- a/include/afb/afb-event-itf.h +++ b/include/afb/afb-event-itf.h @@ -32,8 +32,9 @@ struct afb_event_itf int (*broadcast)(void *closure, struct json_object *obj); int (*push)(void *closure, struct json_object *obj); - void (*drop)(void *closure); + void (*unref)(void *closure); const char *(*name)(void *closure); + void (*addref)(void *closure); }; /* @@ -85,21 +86,33 @@ static inline int afb_event_push(struct afb_event event, struct json_object *obj return event.itf->push(event.closure, object); } +/* OBSOLETE */ +#define afb_event_drop afb_event_unref + /* - * Drops the data associated to the 'event' - * After calling this function, the event - * MUST NOT BE USED ANYMORE. + * Gets the name associated to the 'event'. */ -static inline void afb_event_drop(struct afb_event event) +static inline const char *afb_event_name(struct afb_event event) { - event.itf->drop(event.closure); + return event.itf->name(event.closure); } /* - * Gets the name associated to the 'event'. + * Decrease the count of reference to 'event' and + * destroys the event when the reference count falls to zero. */ -static inline const char *afb_event_name(struct afb_event event) +static inline void afb_event_unref(struct afb_event event) { - return event.itf->name(event.closure); + event.itf->unref(event.closure); +} + +/* + * remove one reference to the data associated to the 'event' + * After calling this function, the event + * MUST NOT BE USED ANYMORE. + */ +static inline void afb_event_addref(struct afb_event event) +{ + event.itf->addref(event.closure); } -- cgit 1.2.3-korg