* Author José Bollo <jose.bollo@iot.bzh>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Author José Bollo <jose.bollo@iot.bzh>
*
* Licensed under the Apache License, Version 2.0 (the "License");
.broadcast = (void*)afb_evt_evtid_broadcast,
.push = (void*)afb_evt_evtid_push,
.unref = (void*)afb_evt_evtid_unref,
.broadcast = (void*)afb_evt_evtid_broadcast,
.push = (void*)afb_evt_evtid_push,
.unref = (void*)afb_evt_evtid_unref,
.broadcast = (void*)afb_evt_evtid_hooked_broadcast,
.push = (void*)afb_evt_evtid_hooked_push,
.unref = (void*)afb_evt_evtid_hooked_unref,
.name = (void*)afb_evt_evtid_hooked_name,
.addref = (void*)afb_evt_evtid_hooked_addref
};
.broadcast = (void*)afb_evt_evtid_hooked_broadcast,
.push = (void*)afb_evt_evtid_hooked_push,
.unref = (void*)afb_evt_evtid_hooked_unref,
.name = (void*)afb_evt_evtid_hooked_name,
.addref = (void*)afb_evt_evtid_hooked_addref
};
static struct afb_evtid *evtids = NULL;
static int event_id_counter = 0;
static int event_id_wrapped = 0;
static struct afb_evtid *evtids = NULL;
static int event_id_counter = 0;
static int event_id_wrapped = 0;
{
return hooked_broadcast(evtid->fullname, object, evtid->id, evtid->hookflags);
}
{
return hooked_broadcast(evtid->fullname, object, evtid->id, evtid->hookflags);
}
return hooked_broadcast(event, object, 0, -1);
return hooked_broadcast(event, object, 0, -1);
/* initialize the event */
memcpy(evtid->fullname, fullname, len + 1);
evtid->next = evtids;
/* initialize the event */
memcpy(evtid->fullname, fullname, len + 1);
evtid->next = evtids;
if (evtid->hookflags & afb_hook_flag_evt_create)
afb_hook_evt_create(evtid->fullname, evtid->id);
if (evtid->hookflags & afb_hook_flag_evt_create)
afb_hook_evt_create(evtid->fullname, evtid->id);
afb_hook_evt_addref(evtid->fullname, evtid->id);
return afb_evt_evtid_addref(evtid);
}
afb_hook_evt_addref(evtid->fullname, evtid->id);
return afb_evt_evtid_addref(evtid);
}
if (!__atomic_sub_fetch(&evtid->refcount, 1, __ATOMIC_RELAXED)) {
/* unlinks the event if valid! */
if (!__atomic_sub_fetch(&evtid->refcount, 1, __ATOMIC_RELAXED)) {
/* unlinks the event if valid! */
/* removes all watchers */
while(evtid->watchs != NULL) {
listener = evtid->watchs->listener;
/* removes all watchers */
while(evtid->watchs != NULL) {
listener = evtid->watchs->listener;
afb_hook_evt_unref(evtid->fullname, evtid->id);
afb_evt_evtid_unref(evtid);
}
afb_hook_evt_unref(evtid->fullname, evtid->id);
afb_evt_evtid_unref(evtid);
}
/* not found, allocate a new */
watch = malloc(sizeof *watch);
if (watch == NULL) {
/* not found, allocate a new */
watch = malloc(sizeof *watch);
if (watch == NULL) {
watch->listener = listener;
watch->next_by_listener = listener->watchs;
listener->watchs = watch;
watch->listener = listener;
watch->next_by_listener = listener->watchs;
listener->watchs = watch;
found:
if (watch->activity == 0 && listener->itf->add != NULL)
listener->itf->add(listener->closure, evtid->fullname, evtid->id);
watch->activity++;
found:
if (watch->activity == 0 && listener->itf->add != NULL)
listener->itf->add(listener->closure, evtid->fullname, evtid->id);
watch->activity++;
if (watch->activity == 0 && listener->itf->remove != NULL)
listener->itf->remove(listener->closure, evtid->fullname, evtid->id);
}
if (watch->activity == 0 && listener->itf->remove != NULL)
listener->itf->remove(listener->closure, evtid->fullname, evtid->id);
}
for (evtid = evtids ; evtid ; evtid = evtid->next) {
evtid->hookflags = afb_hook_flags_evt(evtid->fullname);
for (evtid = evtids ; evtid ; evtid = evtid->next) {
evtid->hookflags = afb_hook_flags_evt(evtid->fullname);
* Creates an event of 'fullname' and returns it.
* Returns an event with closure==NULL in case of error.
*/
* Creates an event of 'fullname' and returns it.
* Returns an event with closure==NULL in case of error.
*/
}
/*
* Creates an event of name 'prefix'/'name' and returns it.
* Returns an event with closure==NULL in case of error.
*/
}
/*
* Creates an event of name 'prefix'/'name' and returns it.
* Returns an event with closure==NULL in case of error.
*/
- ? (struct afb_event){ .itf = &afb_evt_hooked_eventid_itf, .closure = &evtid->eventid }
- : (struct afb_event){ .itf = NULL, .closure = NULL };
+#if WITH_AFB_HOOK
+ ? (struct afb_event_x1){ .itf = &afb_evt_hooked_event_x2_itf, .closure = &evtid->eventid }
+#else
+ ? (struct afb_event_x1){ .itf = &afb_evt_event_x2_itf, .closure = &evtid->eventid }
+#endif
+ : (struct afb_event_x1){ .itf = NULL, .closure = NULL };