notifylist: add notifylist class
PATCH 1/2 notifylist: add notifylist class
oFono and iwd projects use a 'watch' pattern to register clients for notifications about object events, such as state changes. This pattern is quite common and both iwd and oFono implement utilities for adding, removing and notifying 'watch' clients. This can be thought of as a primitive signal / slot framework.
Implementing 'watches' properly, including handling possible call stack re-entrancy conditions can be tricky. The notifylist class implements a generic 'watch' framework and aims to be the shared implementation for iwd, oFono and other projects.
--- Makefile.am | 6 +- ell/ell.h | 1 + ell/ell.sym | 7 ++ ell/notifylist.c | 208 +++++++++++++++++++++++++++++++++++++++++++++++ ell/notifylist.h | 53 ++++++++++++ 5 files changed, 273 insertions(+), 2 deletions(-) create mode 100644 ell/notifylist.c create mode 100644 ell/notifylist.h
Makefile.am +4 -2
@@ -63,7 +63,8 @@ pkginclude_HEADERS = ell/ell.h \ ell/cleanup.h \ ell/netconfig.h \ ell/sysctl.h \ - ell/minheap.h + ell/minheap.h \ + ell/notifylist.h lib_LTLIBRARIES = ell/libell.la
@@ -153,7 +154,8 @@ ell_libell_la_SOURCES = $(linux_headers) \ ell/tester.c \ ell/netconfig.c \ ell/sysctl.c \ - ell/minheap.c + ell/minheap.c \ + ell/notifylist.c ell_libell_la_LDFLAGS = -Wl,--no-undefined \ -Wl,--version-script=$(top_srcdir)/ell/ell.sym \
ell/ell.h +1 -0
@@ -53,3 +53,4 @@#include <ell/netconfig.h> #include <ell/sysctl.h> #include <ell/minheap.h> +#include <ell/notifylist.h>
ell/ell.sym +7 -0
@@ -788,6 +788,13 @@ global: /* sysctl */ l_sysctl_get_u32; l_sysctl_set_u32; + /* notifylist */ + l_notifylist_new; + l_notifylist_free; + l_notifylist_add; + l_notifylist_remove; + l_notifylist_notify; + l_notifylist_notify_matches; local: *; };
ell/notifylist.c new file +208 -0
208 lines not on this page · raw message
ell/notifylist.h new file +53 -0
53 lines not on this page · raw message
Signature · 1 line
2.45.0
PATCH 2/2 unit: Add notifylist unit tests
--- Makefile.am | 5 +- unit/test-notifylist.c | 206 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 210 insertions(+), 1 deletion(-) create mode 100644 unit/test-notifylist.c
Makefile.am +4 -1
@@ -207,7 +207,8 @@ unit_tests = unit/test-unit \ unit/test-path \ unit/test-net \ unit/test-sysctl \ - unit/test-minheap + unit/test-minheap \ + unit/test-notifylist dbus_tests = unit/test-hwdb \ unit/test-dbus \
@@ -360,6 +361,8 @@ unit_test_sysctl_LDADD = ell/libell-private.la unit_test_minheap_LDADD = ell/libell-private.la +unit_test_notifylist_LDADD = ell/libell-private.la + unit_test_data_files = unit/settings.test unit/dbus.conf if EXAMPLES
unit/test-notifylist.c new file +206 -0
206 lines not on this page · raw message
Signature · 1 line
2.45.0