Skip to content

Commit

Permalink
libflux: refactor reactor/watcher implementation
Browse files Browse the repository at this point in the history
Problem: the reactor and watcher implementations are unnecessarily
exposed and co-mingled.

Split up reactor.c, reactor.h (public), reactor_private.h into:

reactor.c, reactor_private.h
  Only the reactor struct and implementation.
  Add an accessor for the ev_loop, to be used only in watcher_wrap.c

watcher.c, watcher_private.h
  Only the watcher struct and generic "class" implementation.
  Add accessors to avoid exposing watcher struct details to watcher
  implementations.

watcher_wrap.c
  Wrapped libev watcher implementations.
  These now use watcher accessors rather than directly accessing
  the watcher struct.

A public watcher.h header is added to split out the public watcher
interfaces from reactor.h.  This was not strictly necessary, but
reactor.h was a little busy.  Users are still expected to just include
<flux/core.h>.

Update the zmq watcher, flux_t handle watcher, fbuf watchers, and sdbus
watcher to include watcher_private.h and use watcher accessors.

Replacing the inlines in reactor_private.h with actual functions
in watcher.c necessitated linking some executables with
src/common/libflux/libflux.la (after libflux-core.la).

libev use is now localized to reactor.c and watcher_wrap.c, which should
make transitioning to a new implementation somewhat easier than before.
The code should also be easier to read and navigate.
  • Loading branch information
garlick committed Dec 16, 2024
1 parent 8ac96c8 commit 971eef2
Show file tree
Hide file tree
Showing 19 changed files with 1,033 additions and 859 deletions.
6 changes: 4 additions & 2 deletions src/cmd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,13 @@ flux_job_LDADD = \
$(top_builddir)/src/common/libczmqcontainers/libczmqcontainers.la \
$(top_builddir)/src/common/libdebugged/libdebugged.la \
$(top_builddir)/src/common/libterminus/libterminus.la \
$(fluxcmd_ldadd)
$(fluxcmd_ldadd) \
$(top_builddir)/src/common/libflux/libflux.la

flux_exec_LDADD = \
$(top_builddir)/src/common/libsubprocess/libsubprocess.la \
$(fluxcmd_ldadd)
$(fluxcmd_ldadd) \
$(top_builddir)/src/common/libflux/libflux.la

flux_terminus_LDADD = \
$(top_builddir)/src/common/libterminus/libterminus.la \
Expand Down
4 changes: 4 additions & 0 deletions src/common/libflux/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ fluxcoreinclude_HEADERS = \
handle.h \
connector.h \
reactor.h \
watcher.h \
msg_handler.h \
message.h \
msglist.h \
Expand Down Expand Up @@ -62,6 +63,9 @@ libflux_la_SOURCES = \
connector_local.c \
reactor.c \
reactor_private.h \
watcher.c \
watcher_private.h \
watcher_wrap.c \
hwatcher.c \
msg_handler.c \
message.c \
Expand Down
1 change: 1 addition & 0 deletions src/common/libflux/flux.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "message.h"
#include "handle.h"
#include "reactor.h"
#include "watcher.h"
#include "msg_handler.h"
#include "connector.h"
#include "msglist.h"
Expand Down
2 changes: 1 addition & 1 deletion src/common/libflux/hwatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "src/common/libutil/errno_safe.h"

#include "reactor_private.h"
#include "watcher_private.h"

struct hwatcher {
flux_watcher_t *fd_w;
Expand Down
Loading

0 comments on commit 971eef2

Please sign in to comment.